98# ifndef GENERATE_GRAPH_H
99# define GENERATE_GRAPH_H
107using namespace Aleph;
112 template <
class GT,
class SA>
inline static
117 if (
not g->is_digraph())
160 const double &
xdist,
161 const double &
ydist,
165 typename GT::Node_Iterator it(g);
166 for (
int i = 0; it.has_curr(); it.next_ne(), ++i)
168 auto p = it.get_current_node_ne();
180 output <<
"NODE-TEXT " << i <<
" \"" <<
text_node <<
"\" 0 0" << std::endl;
185 auto a = it.get_current_arc_ne();
194 <<
xdist/5 <<
" L" << std::endl;
208 <<
text_arc <<
"\" 0 0 " << std::endl;
248 const std::string &
rankdir =
"TB",
252 output <<
"// Generated by generate_graphviz() from Aleph-w library. See at:" << std::endl
253 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
254 <<
"// for documentation" << std::endl
255 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
256 <<
"// for using of graphviz system. See at http://graphviz.org/"
257 << std::endl << std::endl;
262 output <<
"digraph {" << std::endl;
267 output <<
"graph {" << std::endl;
270 <<
"rankdir = " <<
rankdir << std::endl
271 <<
"style = none" << std::endl
272 <<
"truecolor=false" << std::endl
273 <<
"ranksep = " <<
ranksep << std::endl
274 <<
"nodesep = " <<
nodesep << std::endl << std::endl;
279 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
283 auto p = it.get_current_node_ne();
287 output <<
"style = bold ";
293 output <<
"]" << std::endl;
300 auto a = it.get_current_arc_ne();
310 output <<
"style = bold ";
316 output <<
"]" << std::endl;
319 output <<
"}" << std::endl;
366 const std::string &
rankdir =
"TB")
368 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
370 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
371 <<
"// for documentation of Aleph-w library" << std::endl
372 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
373 <<
"// for using of graphviz system. See at http://graphviz.org/"
374 << std::endl << std::endl
375 << (g.
is_digraph() ?
"digraph {" :
"graph {") << std::endl
377 <<
"rankdir = " <<
rankdir << std::endl
379 <<
"// Node list" << std::endl
385 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
387 auto p = it.get_current_node_ne();
395 out <<
"]" << std::endl;
400 <<
"// Arc list" << std::endl
407 auto a = it.get_current_arc_ne();
416 out <<
"]" << std::endl;
419 out <<
"}" << std::endl;
451 const std::string &
rankdir =
"LR")
453 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
455 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
456 <<
"// for documentation of Aleph-w library" << std::endl
457 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
458 <<
"// for using of graphviz system. See at http://graphviz.org/"
459 << std::endl << std::endl
460 <<
"digraph {" << std::endl
462 <<
"rankdir = " <<
rankdir << std::endl
464 <<
"// Node list" << std::endl
470 for (
int i = 0; it.has_curr(); it.
next_ne(), ++i)
472 auto p = it.get_current_node_ne();
479 out <<
"]" << std::endl;
484 <<
"// Arc list" << std::endl
487 const std::string
arrow =
"->";
491 auto a = it.get_current_arc_ne();
500 out <<
"]" << std::endl;
503 out <<
"}" << std::endl;
539 const std::string &
rankdir =
"LR")
541 out <<
"// Generated by generate_graphviz() from Aleph-w library" << std::endl
543 <<
"// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
544 <<
"// for documentation of Aleph-w library" << std::endl
545 <<
"// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
546 <<
"// for using of graphviz system. See at http://graphviz.org/"
547 << std::endl << std::endl
548 <<
"digraph {" << std::endl
550 <<
"rankdir = " <<
rankdir << std::endl
551 <<
"rank = same" << std::endl
553 <<
"// Node list" << std::endl
558 size_t rank = 0, i = 0;
562 out <<
"subgraph rank_" << rank << std::endl
564 <<
"label = \"rank " << rank <<
"\"" << std::endl;
568 auto p = it.get_curr();
572 out <<
"]" << std::endl;
574 out <<
"}" << std::endl;
579 <<
"// Arc list" << std::endl
582 const std::string
arrow =
"->";
585 auto a = it.get_current_arc_ne();
594 out <<
"]" << std::endl;
596 out <<
"}" << std::endl;
685 const std::string &
rankdir =
"LR")
694 const std::string &
rankdir =
"LR")
703 const std::string &
rankdir =
"LR")
759 const std::string &
rankdir =
"TB",
794 const double &
xdist,
795 const double &
ydist,
799 out <<
"cross-net-digraph ";
801 out <<
"cross-net-graph ";
816 const double &
xdist,
817 const double &
ydist,
850 const double &
xdist,
851 const double &
ydist,
855 out <<
"net-digraph ";
872 const double &
xdist,
873 const double &
ydist,
900 template <
class GT,
class Write_Node,
class Write_Arc,
class SA>
903 const double &
xdist,
904 const double &
ydist,
912 template <
class GT,
class Write_Node,
class Write_Arc,
class SA>
915 const double &
xdist,
916 const double &
ydist,
925 template <
class GT,
class Write_Node,
class Write_Arc>
928 const double &
xdist,
929 const double &
ydist,
938 template <
class GT,
class Write_Node,
class Write_Arc>
941 const double &
xdist,
942 const double &
ydist,
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
Dynamic map implemented with a treap.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
size_t size() const noexcept
Count the number of elements of the list.
_Graph_Node Node
The graph type.
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.
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
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.
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
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.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.
Arc of graph implemented with double-linked adjacency lists.
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.