20 #include <ripple/beast/unit_test.h>
21 #include <test/csf/Digraph.h>
36 using Graph = Digraph<char,std::string>;
39 BEAST_EXPECT(!graph.connected(
'a',
'b'));
40 BEAST_EXPECT(!graph.edge(
'a',
'b'));
41 BEAST_EXPECT(!graph.disconnect(
'a',
'b'));
43 BEAST_EXPECT(graph.connect(
'a',
'b',
"foobar"));
44 BEAST_EXPECT(graph.connected(
'a',
'b'));
45 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"foobar");
47 BEAST_EXPECT(!graph.connect(
'a',
'b',
"repeat"));
48 BEAST_EXPECT(graph.disconnect(
'a',
'b'));
49 BEAST_EXPECT(graph.connect(
'a',
'b',
"repeat"));
50 BEAST_EXPECT(graph.connected(
'a',
'b'));
51 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"repeat");
54 BEAST_EXPECT(graph.connect(
'a',
'c',
"tree"));
59 for (
auto const & edge : graph.outEdges(
'a'))
67 BEAST_EXPECT(edges == expected);
68 BEAST_EXPECT(graph.outDegree(
'a') == expected.
size());
71 BEAST_EXPECT(graph.outEdges(
'r').size() == 0);
72 BEAST_EXPECT(graph.outDegree(
'r') == 0);
73 BEAST_EXPECT(graph.outDegree(
'c') == 0);
76 BEAST_EXPECT(graph.outVertices().size() == 1);
79 BEAST_EXPECT((graph.outVertices(
'a') == expected));
80 BEAST_EXPECT(graph.outVertices(
'b').size() == 0);
81 BEAST_EXPECT(graph.outVertices(
'c').size() == 0);
82 BEAST_EXPECT(graph.outVertices(
'r').size() == 0);
85 graph.saveDot(ss, [](
char v) {
return v;});
90 BEAST_EXPECT(ss.
str() == expectedDot);