65 for (
int j = 0; j < n; ++j) {
66 for (
int k = j + 1; k < n; ++k) {
74 bool nodes_resize_policy,
76 bool edges_resize_policy) :
103 std::stringstream output;
104 std::stringstream nodeStream;
105 std::stringstream edgeStream;
107 output <<
"digraph \"no_name\" {\nedge [dir=none]\n";
108 nodeStream <<
"node [shape = ellipse];\n";
109 std::string tab =
" ";
111 for (
const auto node:
nodes()) {
112 nodeStream << std::format(
"{}{}{};", tab, node,
dotNodeLabel(node));
116 if (!treatedNodes.
exists(nei)) edgeStream << std::format(
"{}{} -> {};\n", tab, node, nei);
118 treatedNodes.
insert(node);
121 output << nodeStream.str() <<
'\n' << edgeStream.str() <<
'\n' <<
"}\n";
130 for (
const auto node:
nodes) {
EdgeGraphPart(Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
virtual std::string toString() const
to friendly display the content of the EdgeGraphPart
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
Generic doubly linked lists.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
bool exists(const Val &val) const
Checks whether there exists a given element in the list.
Size size() const
alias for sizeNodes
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
virtual std::string toString() const
a function to display the set of nodes
std::string dotNodeLabel(NodeId id) const
returns " [label=\"...\"]" with DOT-escaped name, or "" if no name
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
std::vector< NodeId > addNodes(Size n)
insert n nodes
Base class for undirected graphs.
virtual std::string toDot() const
to friendly display graph in DOT format
static UndiGraph completeGraph(int n)
create a complete UndiGraph with n nodes
void addEdge(NodeId first, NodeId second) override
insert a new edge into the undirected graph
~UndiGraph() override
destructor
std::string toString() const override
to friendly display the content of the graph
virtual UndiGraph partialUndiGraph(NodeSet nodes)
returns the partial graph formed by the nodes given in parameter
UndiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
some utils for topology : NodeId, Edge, Arc and consorts ...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Generic BFS-based path-finding algorithms for aGrUM graphs.
Base classes for undirected graphs.
Inline implementation of Base classes for undirected graphs.