Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
generate_graph.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
98# ifndef GENERATE_GRAPH_H
99# define GENERATE_GRAPH_H
100
101# include <ah-graph-concepts.H>
102
103# include <fstream>
104# include <tpl_dynArray.H>
105# include <tpl_sort_utils.H>
106# include <tpl_graph.H>
107# include <topological_sort.H>
108
109using namespace Aleph;
110
111namespace Aleph {
112
113
119 template <AlephGraph GT, ArcFilter<GT> SA> inline static
120 bool is_there_a_double_arc(const GT * g,
121 typename GT::Node * src,
122 typename GT::Node * tgt,
123 const SA & sa) noexcept(nothrow_arc_filter_v<GT, SA>)
124 {
125 if (not g->is_digraph())
126 return false;
127
128 return search_arc<GT,SA>(*g, src, tgt, sa) != nullptr and
129 search_arc<GT,SA>(*g, tgt, src, sa) != nullptr;
130 }
131
132
133 template <AlephGraph GT>
135 typename GT::Node * p) noexcept
136 {
137 return sequential_search(nodes, p, 0, nodes.size() - 1);
138 }
139
140
165 template <AlephGraph GT,
166 class Write_Node, class Write_Arc,
167 class Shade_Node, class Shade_Arc, ArcFilter<GT> SA>
168 void generate_graphpic(const GT & g,
169 const double & xdist,
170 [[maybe_unused]] const double & ydist,
171 std::ostream & output,
172 SA sa = SA())
173 {
175 typename GT::Node_Iterator it(g);
176 for (int i = 0; it.has_curr(); it.next_ne(), ++i)
177 {
178 auto p = it.get_current_node_ne();
179
180 nodes[i] = p;
181
182 if (Shade_Node() (p).size() != 0)
183 output << Shade_Node() (p) << " " << i << std::endl;
184
185 const std::string text_node = Write_Node () (p);
186
187 if (text_node.size() == 0)
188 continue;
189
190 output << "NODE-TEXT " << i << " \"" << text_node << "\" 0 0" << std::endl;
191 }
192
193 for (Arc_Iterator<GT, SA> it(g, sa); it.has_curr(); it.next_ne())
194 {
195 auto a = it.get_current_arc_ne();
196 auto src = g.get_src_node(a);
197 auto tgt = g.get_tgt_node(a);
198
199 const auto src_idx = search_node <GT> (nodes, src);
200 const auto tgt_idx = search_node <GT> (nodes, tgt);
201
202 if (is_there_a_double_arc <GT, SA> (&g, src, tgt, sa))
203 output << "CURVE-ARC " << src_idx << " " << tgt_idx << " "
204 << xdist/5 << " L" << std::endl;
205 else
206 output << "ARC " << src_idx << " " << tgt_idx << std::endl;
207
208 if ( Shade_Arc()(a).size() != 0)
209 output << Shade_Arc()(a) << " "
210 << src_idx << " " << tgt_idx << " " << std::endl;
211
212 const std::string text_arc = Write_Arc() (a);
213
214 if (text_arc.size() == 0)
215 continue;
216
217 output << "ARC-TEXT " << src_idx << " " << tgt_idx << " \""
218 << text_arc << "\" 0 0 " << std::endl;
219 }
220 }
221
249 template <AlephGraph GT,
250 class Write_Node,
251 class Write_Arc,
252 class Shade_Node,
253 class Shade_Arc,
254 class Dashed_Node,
255 class Dashed_Arc,
256 ArcFilter<GT> SA,
257 NodeFilter<GT> SN>
258 void generate_graphviz(const GT & g, std::ostream & output,
259 const std::string & rankdir = "TB",
260 float ranksep = 0.2,
261 float nodesep = 0.2,
262 SA sa = SA())
263 {
264 output << "// Generated by generate_graphviz() from Aleph-w library. See at:" << std::endl
265 << "// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
266 << "// for documentation" << std::endl
267 << "// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
268 << "// for using of graphviz system. See at http://graphviz.org/"
269 << std::endl << std::endl;
270 std::string arc_str;
271 if (g.is_digraph())
272 {
273 arc_str = " -> ";
274 output << "digraph {" << std::endl;
275 }
276 else
277 {
278 arc_str = " -- ";
279 output << "graph {" << std::endl;
280 }
281 output << std::endl
282 << "rankdir = " << rankdir << std::endl
283 << "style = none" << std::endl
284 << "truecolor=false" << std::endl
285 << "ranksep = " << ranksep << std::endl
286 << "nodesep = " << nodesep << std::endl << std::endl;
287
289
291 for (int i = 0; it.has_curr(); it.next_ne(), ++i)
292 {
293 output << i << " [ ";
294
295 auto p = it.get_current_node_ne();
296 nodes[i] = p;
297
298 if (Shade_Node () (p))
299 output << "style = bold ";
300
301 const std::string text_node = Write_Node () (p);
302
303 if (text_node.size() != 0)
304 output << "label = \"" << text_node << "\"";
305 output << "]" << std::endl;
306 }
307
308 output << std::endl;
309
310 for (Arc_Iterator<GT, SA> it(g, sa); it.has_curr(); it.next_ne())
311 {
312 auto a = it.get_current_arc_ne();
313 auto src = g.get_src_node(a);
314 auto tgt = g.get_tgt_node(a);
315
316 auto src_idx = search_node <GT> (nodes, src);
317 auto tgt_idx = search_node <GT> (nodes, tgt);
318
319 output << src_idx << arc_str << tgt_idx << " [";
320
321 if (Shade_Arc () (a))
322 output << "style = bold ";
323
324 const std::string text_arc = Write_Arc() (a);
325
326 if (text_arc.size() != 0)
327 output << "label = \"" << text_arc << "\"";
328 output <<"]" << std::endl;
329 }
330
331 output << "}" << std::endl;
332 }
333
334
371 template <AlephGraph GT,
372 class Node_Attr,
373 class Arc_Attr,
374 NodeFilter<GT> SN,
375 ArcFilter<GT> SA>
376 void generate_graphviz(const GT & g, std::ostream & out,
377 Node_Attr node_attr = Node_Attr(),
378 Arc_Attr arc_attr = Arc_Attr(),
379 const std::string & rankdir = "TB",
380 SA sa = SA())
381 {
382 out << "// Generated by generate_graphviz() from Aleph-w library" << std::endl
383 << "// See at:"
384 << "// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
385 << "// for documentation of Aleph-w library" << std::endl
386 << "// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
387 << "// for using of graphviz system. See at http://graphviz.org/"
388 << std::endl << std::endl
389 << (g.is_digraph() ? "digraph {" : "graph {") << std::endl
390 << std::endl
391 << "rankdir = " << rankdir << std::endl
392 << std::endl
393 << "// Node list" << std::endl
394 << std::endl;
395
397
399 for (int i = 0; it.has_curr(); it.next_ne(), ++i)
400 {
401 auto p = it.get_current_node_ne();
402
403 nodes_table.insert(p, i);
404
405 out << i << " [ ";
406
407 node_attr (g, p, out);
408
409 out << "]" << std::endl;
410 }
411
412 out << std::endl
413 << std::endl
414 << "// Arc list" << std::endl
415 << std::endl;
416
417 const std::string arrow = g.is_digraph() ? "->" : "--";
418
419 for (Arc_Iterator<GT, SA> it(g, sa); it.has_curr(); it.next_ne())
420 {
421 auto a = it.get_current_arc_ne();
422 auto src = g.get_src_node(a);
423 auto tgt = g.get_tgt_node(a);
424
425 const auto src_idx = nodes_table.find(src);
426 const auto tgt_idx = nodes_table.find(tgt);
427
428 out << src_idx << arrow << tgt_idx << " [";
429 arc_attr (g, a, out) ;
430 out << "]" << std::endl;
431 }
432
433 out << "}" << std::endl;
434 }
435
458 template <AlephGraph GT,
459 class Node_Attr,
460 class Arc_Attr,
461 NodeFilter<GT> SN,
462 ArcFilter<GT> SA>
463 void digraph_graphviz(const GT & g, std::ostream & out,
464 Node_Attr node_attr = Node_Attr(),
465 Arc_Attr arc_attr = Arc_Attr(),
466 const std::string & rankdir = "LR",
467 SA sa = SA())
468 {
469 out << "// Generated by generate_graphviz() from Aleph-w library" << std::endl
470 << "// See at:"
471 << "// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
472 << "// for documentation of Aleph-w library" << std::endl
473 << "// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
474 << "// for using of graphviz system. See at http://graphviz.org/"
475 << std::endl << std::endl
476 << "digraph {" << std::endl
477 << std::endl
478 << "rankdir = " << rankdir << std::endl
479 << std::endl
480 << "// Node list" << std::endl
481 << std::endl;
482
484
486 for (int i = 0; it.has_curr(); it.next_ne(), ++i)
487 {
488 auto p = it.get_current_node_ne();
489 nodes_table.insert(p, i);
490
491 out << i << " [ ";
492
493 node_attr (g, p, out);
494
495 out << "]" << std::endl;
496 }
497
498 out << std::endl
499 << std::endl
500 << "// Arc list" << std::endl
501 << std::endl;
502
503 const std::string arrow = "->";
504
505 for (Arc_Iterator<GT, SA> it(g, sa); it.has_curr(); it.next_ne())
506 {
507 auto a = it.get_current_arc_ne();
508 auto src = g.get_src_node(a);
509 auto tgt = g.get_tgt_node(a);
510
511 const auto src_idx = nodes_table.find(src);
512 const auto tgt_idx = nodes_table.find(tgt);
513
514 out << src_idx << arrow << tgt_idx << " [";
515 arc_attr (g, a, out) ;
516 out << "]" << std::endl;
517 }
518
519 out << "}" << std::endl;
520 }
521
549 template <AlephGraph GT,
550 class Node_Attr,
551 class Arc_Attr,
552 NodeFilter<GT> SN,
553 ArcFilter<GT> SA>
554 size_t rank_graphviz(const GT & g, std::ostream & out,
555 Node_Attr node_attr = Node_Attr(),
556 Arc_Attr arc_attr = Arc_Attr(),
557 const std::string & rankdir = "LR",
558 SA sa = SA())
559 {
560 out << "// Generated by generate_graphviz() from Aleph-w library" << std::endl
561 << "// See at:"
562 << "// http://webdelprofesor.ula.ve/ingenieria/lrleon/aleph/html/index.html" << std::endl
563 << "// for documentation of Aleph-w library" << std::endl
564 << "// Copyleft Leandro Rabindranath Leon lrleon@ula.ve" << std::endl
565 << "// for using of graphviz system. See at http://graphviz.org/"
566 << std::endl << std::endl
567 << "digraph {" << std::endl
568 << std::endl
569 << "rankdir = " << rankdir << std::endl
570 << "rank = same" << std::endl
571 << std::endl
572 << "// Node list" << std::endl
573 << std::endl;
574
578 size_t rank = 0, i = 0;
579 for (auto rank_it = ranks.get_it(); rank_it.has_curr();
580 rank_it.next_ne(), ++rank)
581 {
582 out << "subgraph rank_" << rank << std::endl
583 << "{" << std::endl
584 << "label = \"rank " << rank << "\"" << std::endl;
585 for (auto it = rank_it.get_curr().get_it(); it.has_curr();
586 it.next_ne(), ++i)
587 {
588 auto p = it.get_curr();
589 nodes_table.insert(p, i);
590 out << i << " [ ";
591 node_attr(g, p, out);
592 out << "]" << std::endl;
593 }
594 out << "}" << std::endl;
595 }
596
597 out << std::endl
598 << std::endl
599 << "// Arc list" << std::endl
600 << std::endl;
601
602 const std::string arrow = "->";
603 for (Arc_Iterator<GT, SA> it(g, sa); it.has_curr(); it.next_ne())
604 {
605 auto a = it.get_current_arc_ne();
606 auto src = g.get_src_node(a);
607 auto tgt = g.get_tgt_node(a);
608
609 const auto src_idx = nodes_table.find(src);
610 const auto tgt_idx = nodes_table.find(tgt);
611
612 out << src_idx << arrow << tgt_idx << " [";
613 arc_attr (g, a, out) ;
614 out << "]" << std::endl;
615 }
616 out << "}" << std::endl;
617
618 return rank;
619 }
620
621 template <class GT>
623 {
624 void operator () (const GT&, typename GT::Node * p, std::ostream & out)
625 {
626 out << "label = \"" << p->get_info() << "\"";
627 }
628 };
629
630 template <class GT>
632 {
633 void operator () (const GT&, typename GT::Arc * a, std::ostream & out)
634 {
635 out << "label = \"" << a->get_info() << "\"";
636 }
637 };
638
687 template <AlephGraph GT,
688 class Node_Attr = Dft_Node_Attr<GT>,
689 class Arc_Attr = Dft_Arc_Attr<GT>,
690 NodeFilter<GT> SN = Dft_Show_Node<GT>,
691 ArcFilter<GT> SA = Dft_Show_Arc<GT>>
693 {
694 SA sa;
695
697 explicit To_Graphviz(SA __sa = SA()) : sa(std::move(__sa)) {}
698
707 void operator () (const GT & g, std::ostream & out,
708 const Node_Attr & node_attr = Node_Attr(),
709 const Arc_Attr & arc_attr = Arc_Attr(),
710 const std::string & rankdir = "LR")
711 {
712 generate_graphviz <GT, Node_Attr, Arc_Attr, SN, SA>
713 (g, out, node_attr, arc_attr, rankdir, sa);
714 }
715
716 void digraph(const GT & g, std::ostream & out,
717 const Node_Attr & node_attr = Node_Attr(),
718 const Arc_Attr & arc_attr = Arc_Attr(),
719 const std::string & rankdir = "LR")
720 {
721 digraph_graphviz <GT, Node_Attr, Arc_Attr, SN, SA>
722 (g, out, node_attr, arc_attr, rankdir, sa);
723 }
724
725 void ranks(const GT & g, std::ostream & out,
726 const Node_Attr & node_attr = Node_Attr(),
727 const Arc_Attr & arc_attr = Arc_Attr(),
728 const std::string & rankdir = "LR")
729 {
730 rank_graphviz <GT, Node_Attr, Arc_Attr, SN, SA>
731 (g, out, node_attr, arc_attr, rankdir, sa);
732 }
733 };
734
735
736
737 template <AlephGraph GT>
739 {
740 bool operator () (typename GT::Node *) const { return false; }
741
742 bool operator () (typename GT::Arc *) const { return false; }
743 };
744
745
764 template <AlephGraph GT,
765 class Write_Node,
766 class Write_Arc,
767 class Shade_Node = Dummy_Attr<GT>,
768 class Shade_Arc = Dummy_Attr<GT>,
769 class Dashed_Node = Dummy_Attr<GT>,
770 class Dashed_Arc = Dummy_Attr<GT>,
771 ArcFilter<GT> SA = Dft_Show_Arc<GT>,
772 NodeFilter<GT> SN = Dft_Show_Node<GT> >
774 {
775 SA sa;
776
778 explicit Generate_Graphviz(SA __sa = SA()) : sa(std::move(__sa)) {}
779
788 void operator () (GT & g, std::ostream & out,
789 const std::string & rankdir = "TB",
790 float ranksep = 0.4, float nodesep = 0.4)
791 {
792 generate_graphviz <GT, Write_Node, Write_Arc, Shade_Node,
793 Shade_Arc, Dashed_Node, Dashed_Arc, SA, SN>
794 (g, out, rankdir, ranksep, nodesep, sa);
795 }
796 };
797
820 template <AlephGraph GT,
821 class Write_Node, class Write_Arc,
822 class Shade_Node, class Shade_Arc, ArcFilter<GT> SA>
824 const size_t & nodes_by_level,
825 const double & xdist,
826 const double & ydist,
827 std::ostream & out,
828 SA sa = SA())
829 {
830 if (g.is_digraph())
831 out << "cross-net-digraph ";
832 else
833 out << "cross-net-graph ";
834
835 out << g.get_num_nodes() << " " << nodes_by_level << " "
836 << xdist << " " << ydist << std::endl
837 << std::endl;
838
839 generate_graphpic<GT, Write_Node, Write_Arc, Shade_Node, Shade_Arc, SA>
840 (g, xdist, ydist, out, sa);
841 }
842
843 template <AlephGraph GT,
844 class Write_Node, class Write_Arc,
845 class Shade_Node, class Shade_Arc>
847 const size_t & nodes_by_level,
848 const double & xdist,
849 const double & ydist,
850 std::ostream & out)
851 {
852 typedef Dft_Show_Arc<GT> DSA;
853 generate_cross_graph<GT, Write_Node, Write_Arc, Shade_Node, Shade_Arc, DSA>
854 (g, nodes_by_level, xdist, ydist, out);
855 }
856
878 template <AlephGraph GT,
879 class Write_Node, class Write_Arc,
880 class Shade_Node, class Shade_Arc, ArcFilter<GT> SA>
882 const size_t & nodes_by_level,
883 const double & xdist,
884 const double & ydist,
885 std::ostream & out,
886 SA sa = SA())
887 {
888 if (g.is_digraph())
889 out << "net-digraph ";
890 else
891 out << "net-graph ";
892
893 out << g.get_num_nodes() << " " << nodes_by_level << " "
894 << xdist << " " << ydist << std::endl
895 << std::endl;
896
897 generate_graphpic<GT, Write_Node, Write_Arc, Shade_Node, Shade_Arc, SA>
898 (g, xdist, ydist, out, sa);
899 }
900
901 template <AlephGraph GT,
902 class Write_Node, class Write_Arc,
903 class Shade_Node, class Shade_Arc>
905 const size_t & nodes_by_level,
906 const double & xdist,
907 const double & ydist,
908 std::ostream & out)
909 {
910 typedef Dft_Show_Arc<GT> DSA;
911 generate_net_graph<GT, Write_Node, Write_Arc, Shade_Node, Shade_Arc, DSA>
912 (g, nodes_by_level, xdist, ydist, out);
913
914 }
915
916 template <AlephGraph GT> struct __Shade_Node
917 {
918 std::string operator () (typename GT::Node *) const
919 {
920 return "";
921 }
922 };
923
924
925 template <AlephGraph GT> struct __Shade_Arc
926 {
927 std::string operator () (typename GT::Arc *) const
928 {
929 return "";
930 }
931 };
932
933
934 template <AlephGraph GT, class Write_Node, class Write_Arc, ArcFilter<GT> SA>
936 const size_t & nodes_by_level,
937 const double & xdist,
938 const double & ydist,
939 std::ostream & out,
940 SA sa = SA())
941 {
943 <GT, Write_Node, Write_Arc, __Shade_Node<GT>, __Shade_Arc<GT>, SA>
944 (g, nodes_by_level, xdist, ydist, out, sa);
945 }
946
947 template <AlephGraph GT, class Write_Node, class Write_Arc, ArcFilter<GT> SA>
949 const size_t & nodes_by_level,
950 const double & xdist,
951 const double & ydist,
952 std::ostream & out,
953 SA sa = SA())
954 {
956 <GT, Write_Node, Write_Arc, __Shade_Node<GT>, __Shade_Arc<GT>, SA>
957 (g, nodes_by_level, xdist, ydist, out, sa);
958 }
959
960
961 template <AlephGraph GT, class Write_Node, class Write_Arc>
963 const size_t & nodes_by_level,
964 const double & xdist,
965 const double & ydist,
966 std::ostream & out)
967 {
968 typedef Dft_Show_Arc<GT> DSA;
970 <GT, Write_Node, Write_Arc, __Shade_Node<GT>, __Shade_Arc<GT>, DSA>
971 (g, nodes_by_level, xdist, ydist, out);
972 }
973
974 template <AlephGraph GT, class Write_Node, class Write_Arc>
976 const size_t & nodes_by_level,
977 const double & xdist,
978 const double & ydist,
979 std::ostream & out)
980 {
981 typedef Dft_Show_Arc<GT> DSA;
983 <GT, Write_Node, Write_Arc, __Shade_Node<GT>, __Shade_Arc<GT>, DSA>
984 (g, nodes_by_level, xdist, ydist, out);
985 }
986
987
988} // end namespace Aleph
989
990
991# endif // GENERATE_GRAPH_H
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
Definition ca-c-api.h:120
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1231
Dynamic map implemented with a treap.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Data & find(const Key &key)
Find the value associated with key.
void next_ne() noexcept(shows_ne)
Advances the iterator to the next filtered element, as next() does.
Filtered iterator on the nodes of a graph.
Definition tpl_graph.H:1287
Computes topological ordering using breadth-first search (Kahn's algorithm).
RankList< List< typename GT::Node * > > ranks(const GT &g)
Compute rank-based topological ordering.
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
Definition graph-dry.H:854
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Definition graph-dry.H:753
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Definition graph-dry.H:975
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Definition graph-dry.H:1017
bool is_digraph() const noexcept
Return true if the graph this is directed.
Definition graph-dry.H:937
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
Definition graph-dry.H:1023
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Definition ah-dry.H:663
DynArray< Graph::Node * > nodes
Definition graphpic.C:406
void generate_graphviz(const GT &g, std::ostream &output, const std::string &rankdir="TB", float ranksep=0.2, float nodesep=0.2, SA sa=SA())
Generate a Graphviz DOT specification for graph visualization.
void generate_graphpic(const GT &g, const double &xdist, const double &ydist, std::ostream &output, SA sa=SA())
Generate a graphpic 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, SA sa=SA())
Generate a net-graph layout specification for graphpic.
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", SA sa=SA())
Generate Graphviz DOT output specifically for digraphs.
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", SA sa=SA())
Generate Graphviz DOT output with topological ranking.
void generate_cross_graph(GT &g, const size_t &nodes_by_level, const double &xdist, const double &ydist, std::ostream &out, SA sa=SA())
Generate a cross-graph layout specification for graphpic.
Main namespace for Aleph-w library functions.
size_t size(Node *root) noexcept
See compute_cardinality_rec(Node * root).
static int search_node(DynArray< typename GT::Node * > &nodes, typename GT::Node *p) noexcept
and
Check uniqueness with explicit hash + equality functors.
static bool is_there_a_double_arc(const GT *g, typename GT::Node *src, typename GT::Node *tgt, const SA &sa) noexcept(nothrow_arc_filter_v< GT, SA >)
Whether the digraph g has, among the arcs that sa shows, an arc from src to tgt and another from tgt ...
Array< size_t > ranks(const Array< T > &array)
Computes the rank of each element in an Array.
Definition ahSort.H:696
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.
STL namespace.
Filtered iterator on all the arcs of a graph.
Definition tpl_graph.H:1200
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.
Definition tpl_graph.H:1024
Default filter for the graph nodes.
Definition tpl_graph.H:1228
bool operator()(typename GT::Node *) const
Functor for generating Graphviz specifications.
SA sa
the filter of the arcs, which each generation copies
Generate_Graphviz(SA __sa=SA())
Keeps sa, the filter of the arcs.
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")
SA sa
the filter of the arcs, which each generation copies
To_Graphviz(SA __sa=SA())
Keeps sa, the filter of the arcs.
std::string operator()(typename GT::Arc *) const
std::string operator()(typename GT::Node *) const
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.
ofstream output
Definition writeHeap.C:215