98# ifndef GENERATE_GRAPH_H
99# define GENERATE_GRAPH_H
109using namespace Aleph;
114 template <AlephGraph GT, ArcFilter<GT> SA>
inline static
119 if (
not g->is_digraph())
127 template <AlephGraph GT>
158 template <AlephGraph
GT,
162 const double &
xdist,
163 const double &
ydist,
167 typename GT::Node_Iterator it(g);
168 for (
int i = 0; it.has_curr(); it.next_ne(), ++i)
170 auto p = it.get_current_node_ne();
182 output <<
"NODE-TEXT " << i <<
" \"" <<
text_node <<
"\" 0 0" << std::endl;
187 auto a = it.get_current_arc_ne();
196 <<
xdist/5 <<
" L" << std::endl;
202 << src_idx <<
" " <<
tgt_idx <<
" " << std::endl;
210 <<
text_arc <<
"\" 0 0 " << std::endl;
240 template <AlephGraph
GT,
250 const std::string &
rankdir =
"TB",
254 output <<
"// Generated by generate_graphviz() from Aleph-w library. See at:" << std::endl
255 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
256 <<
"// for documentation" << std::endl
257 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
258 <<
"// for using of graphviz system. See at http://graphviz.org/"
259 << std::endl << std::endl;
264 output <<
"digraph {" << std::endl;
269 output <<
"graph {" << std::endl;
272 <<
"rankdir = " <<
rankdir << std::endl
273 <<
"style = none" << std::endl
274 <<
"truecolor=false" << std::endl
275 <<
"ranksep = " <<
ranksep << std::endl
276 <<
"nodesep = " <<
nodesep << std::endl << std::endl;
281 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
285 auto p = it.get_current_node_ne();
289 output <<
"style = bold ";
295 output <<
"]" << std::endl;
302 auto a = it.get_current_arc_ne();
312 output <<
"style = bold ";
318 output <<
"]" << std::endl;
321 output <<
"}" << std::endl;
360 template <AlephGraph
GT,
368 const std::string &
rankdir =
"TB")
370 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
372 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
373 <<
"// for documentation of Aleph-w library" << std::endl
374 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
375 <<
"// for using of graphviz system. See at http://graphviz.org/"
376 << std::endl << std::endl
377 << (g.
is_digraph() ?
"digraph {" :
"graph {") << std::endl
379 <<
"rankdir = " <<
rankdir << std::endl
381 <<
"// Node list" << std::endl
387 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
389 auto p = it.get_current_node_ne();
397 out <<
"]" << std::endl;
402 <<
"// Arc list" << std::endl
409 auto a = it.get_current_arc_ne();
418 out <<
"]" << std::endl;
421 out <<
"}" << std::endl;
445 template <AlephGraph
GT,
453 const std::string &
rankdir =
"LR")
455 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
457 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
458 <<
"// for documentation of Aleph-w library" << std::endl
459 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
460 <<
"// for using of graphviz system. See at http://graphviz.org/"
461 << std::endl << std::endl
462 <<
"digraph {" << std::endl
464 <<
"rankdir = " <<
rankdir << std::endl
466 <<
"// Node list" << std::endl
472 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
474 auto p = it.get_current_node_ne();
481 out <<
"]" << std::endl;
486 <<
"// Arc list" << std::endl
489 const std::string
arrow =
"->";
493 auto a = it.get_current_arc_ne();
502 out <<
"]" << std::endl;
505 out <<
"}" << std::endl;
533 template <AlephGraph
GT,
541 const std::string &
rankdir =
"LR")
543 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
545 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
546 <<
"// for documentation of Aleph-w library" << std::endl
547 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
548 <<
"// for using of graphviz system. See at http://graphviz.org/"
549 << std::endl << std::endl
550 <<
"digraph {" << std::endl
552 <<
"rankdir = " <<
rankdir << std::endl
553 <<
"rank = same" << std::endl
555 <<
"// Node list" << std::endl
560 size_t rank = 0, i = 0;
564 out <<
"subgraph rank_" << rank << std::endl
566 <<
"label = \"rank " << rank <<
"\"" << std::endl;
567 for (
auto it =
rank_it.get_curr().get_it(); it.has_curr();
570 auto p = it.get_curr();
574 out <<
"]" << std::endl;
576 out <<
"}" << std::endl;
581 <<
"// Arc list" << std::endl
584 const std::string
arrow =
"->";
587 auto a = it.get_current_arc_ne();
596 out <<
"]" << std::endl;
598 out <<
"}" << std::endl;
669 template <AlephGraph
GT,
687 const std::string &
rankdir =
"LR")
696 const std::string &
rankdir =
"LR")
705 const std::string &
rankdir =
"LR")
714 template <AlephGraph GT>
741 template <AlephGraph
GT,
761 const std::string &
rankdir =
"TB",
791 template <AlephGraph
GT,
796 const double &
xdist,
797 const double &
ydist,
801 out <<
"cross-net-digraph ";
803 out <<
"cross-net-graph ";
813 template <AlephGraph
GT,
818 const double &
xdist,
819 const double &
ydist,
847 template <AlephGraph
GT,
852 const double &
xdist,
853 const double &
ydist,
857 out <<
"net-digraph ";
869 template <AlephGraph
GT,
874 const double &
xdist,
875 const double &
ydist,
902 template <AlephGraph GT,
class Write_Node,
class Write_Arc, ArcFilter<GT> SA>
905 const double &
xdist,
906 const double &
ydist,
914 template <AlephGraph GT,
class Write_Node,
class Write_Arc, ArcFilter<GT> SA>
917 const double &
xdist,
918 const double &
ydist,
927 template <AlephGraph GT,
class Write_Node,
class Write_Arc>
930 const double &
xdist,
931 const double &
ydist,
940 template <AlephGraph GT,
class Write_Node,
class Write_Arc>
943 const double &
xdist,
944 const double &
ydist,
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
size_t size_t int32_t * out
T & insert(const T &data)
insert a copy of data at the beginning of the array.
Doubly-linked list (defined in tpl_dynList.H).
Dynamic map implemented with a treap.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
Filtered iterator on the nodes of a graph.
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
bool is_digraph() const noexcept
Return true if the graph this is directed.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
DynArray< Graph::Node * > nodes
size_t rank_graphviz(const GT &g, std::ostream &out, Node_Attr node_attr=Node_Attr(), Arc_Attr arc_attr=Arc_Attr(), const std::string &rankdir="LR")
Generate Graphviz DOT output with topological ranking.
void digraph_graphviz(const GT &g, std::ostream &out, Node_Attr node_attr=Node_Attr(), Arc_Attr arc_attr=Arc_Attr(), const std::string &rankdir="LR")
Generate Graphviz DOT output specifically for digraphs.
void generate_graphpic(const GT &g, const double &xdist, const double &ydist, std::ostream &output)
Generate a graphpic specification for graph visualization.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void generate_cross_graph(GT &g, const size_t &nodes_by_level, const double &xdist, const double &ydist, std::ostream &out)
Generate a cross-graph layout specification for graphpic.
void generate_graphviz(const GT &g, std::ostream &output, const std::string &rankdir="TB", float ranksep=0.2, float nodesep=0.2)
Generate a Graphviz DOT specification for graph visualization.
void generate_net_graph(GT &g, const size_t &nodes_by_level, const double &xdist, const double &ydist, std::ostream &out)
Generate a net-graph layout specification for graphpic.
Main namespace for Aleph-w library functions.
size_t size(Node *root) noexcept
static int search_node(DynArray< typename GT::Node * > &nodes, typename GT::Node *p) noexcept
and
Check uniqueness with explicit hash + equality functors.
Array< size_t > ranks(const Array< T > &array)
Computes the rank of each element in an Array.
long sequential_search(T *a, const T &x, const long l, const long r, Equal eq=Equal())
Linear search for an element in an array.
static bool is_there_a_double_arc(const GT *g, typename GT::Node *src, typename GT::Node *tgt) noexcept
Filtered iterator on all the arcs of a graph.
void operator()(const GT &, typename GT::Arc *a, std::ostream &out)
void operator()(const GT &, typename GT::Node *p, std::ostream &out)
Default filter for filtered iterators on arcs.
Default filter for the graph nodes.
bool operator()(typename GT::Node *) const
Functor for generating Graphviz specifications.
void operator()(GT &g, std::ostream &out, const std::string &rankdir="TB", float ranksep=0.4, float nodesep=0.4)
Generate DOT specification for the graph.
Functor class for generating Graphviz DOT specifications.
void operator()(const GT &g, std::ostream &out, const Node_Attr &node_attr=Node_Attr(), const Arc_Attr &arc_attr=Arc_Attr(), const std::string &rankdir="LR")
Generate DOT specification for a graph.
void ranks(const GT &g, std::ostream &out, const Node_Attr &node_attr=Node_Attr(), const Arc_Attr &arc_attr=Arc_Attr(), const std::string &rankdir="LR")
void digraph(const GT &g, std::ostream &out, const Node_Attr &node_attr=Node_Attr(), const Arc_Attr &arc_attr=Arc_Attr(), const std::string &rankdir="LR")
std::string operator()(typename GT::Arc *) const
std::string operator()(typename GT::Node *) const
Writer that outputs only the node key.
Topological sorting algorithms for directed acyclic graphs (DAGs).
Lazy and scalable dynamic array implementation.
Generic graph and digraph implementations.
Comprehensive sorting algorithms and search utilities for Aleph-w.