20 #include <ripple/beast/unit_test.h>
22 #include <test/csf/Digraph.h>
35 using Graph = Digraph<char, std::string>;
38 BEAST_EXPECT(!graph.connected(
'a',
'b'));
39 BEAST_EXPECT(!graph.edge(
'a',
'b'));
40 BEAST_EXPECT(!graph.disconnect(
'a',
'b'));
42 BEAST_EXPECT(graph.connect(
'a',
'b',
"foobar"));
43 BEAST_EXPECT(graph.connected(
'a',
'b'));
44 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"foobar");
46 BEAST_EXPECT(!graph.connect(
'a',
'b',
"repeat"));
47 BEAST_EXPECT(graph.disconnect(
'a',
'b'));
48 BEAST_EXPECT(graph.connect(
'a',
'b',
"repeat"));
49 BEAST_EXPECT(graph.connected(
'a',
'b'));
50 BEAST_EXPECT(*graph.edge(
'a',
'b') ==
"repeat");
52 BEAST_EXPECT(graph.connect(
'a',
'c',
"tree"));
57 for (
auto const& edge : graph.outEdges(
'a'))
65 BEAST_EXPECT(edges == expected);
66 BEAST_EXPECT(graph.outDegree(
'a') == expected.
size());
69 BEAST_EXPECT(graph.outEdges(
'r').size() == 0);
70 BEAST_EXPECT(graph.outDegree(
'r') == 0);
71 BEAST_EXPECT(graph.outDegree(
'c') == 0);
74 BEAST_EXPECT(graph.outVertices().size() == 1);
77 BEAST_EXPECT((graph.outVertices(
'a') == expected));
78 BEAST_EXPECT(graph.outVertices(
'b').size() == 0);
79 BEAST_EXPECT(graph.outVertices(
'c').size() == 0);
80 BEAST_EXPECT(graph.outVertices(
'r').size() == 0);
83 graph.saveDot(ss, [](
char v) {
return v; });
89 BEAST_EXPECT(ss.
str() == expectedDot);