Example #1
0
        /// <summary>
        /// Creates a test graph.
        /// There are light edges between nodes 0 - 1, 1 - 2, and 2 - 0.
        /// There are heavy edges between 0 - 1 and 1 - 3
        /// </summary>
        private static void CreateGraphWithLightEdges(out MutableDirectedGraph graph, out NodeId[] nodes)
        {
            graph = new MutableDirectedGraph();
            XAssert.AreEqual(graph.NodeCount, 0);
            XAssert.AreEqual(graph.EdgeCount, 0);

            // Test creation.
            nodes = new NodeId[4];
            for (int i = 0; i < nodes.Length; ++i)
            {
                nodes[i] = graph.CreateNode();
            }

            XAssert.AreEqual(graph.NodeCount, nodes.Length);
            XAssert.AreEqual(graph.EdgeCount, 0);

            foreach (NodeId t in nodes)
            {
                XAssert.IsTrue(graph.ContainsNode(t));
                XAssert.IsTrue(graph.IsSourceNode(t));
                XAssert.IsTrue(graph.IsSinkNode(t));
            }

            graph.AddEdge(nodes[0], nodes[1], isLight: true);
            graph.AddEdge(nodes[1], nodes[2], isLight: true);
            graph.AddEdge(nodes[2], nodes[0], isLight: true);
            graph.AddEdge(nodes[0], nodes[1], isLight: false);
            graph.AddEdge(nodes[1], nodes[3], isLight: false);
        }
Example #2
0
        /// <summary>
        /// Creates a test graph.
        /// </summary>
        private static void CreateGraph(out MutableDirectedGraph graph, out NodeId[] nodes)
        {
            graph = new MutableDirectedGraph();
            XAssert.AreEqual(graph.NodeCount, 0);
            XAssert.AreEqual(graph.EdgeCount, 0);

            // Test creation.
            nodes = new NodeId[12];
            for (int i = 0; i < nodes.Length; ++i)
            {
                nodes[i] = graph.CreateNode();
            }

            XAssert.AreEqual(graph.NodeCount, nodes.Length);
            XAssert.AreEqual(graph.EdgeCount, 0);

            foreach (NodeId t in nodes)
            {
                XAssert.IsTrue(graph.ContainsNode(t));
                XAssert.IsTrue(graph.IsSourceNode(t));
                XAssert.IsTrue(graph.IsSinkNode(t));
            }

            graph.AddEdge(nodes[5], nodes[0]);
            graph.AddEdge(nodes[5], nodes[1]);
            graph.AddEdge(nodes[6], nodes[1]);
            graph.AddEdge(nodes[6], nodes[2]);
            graph.AddEdge(nodes[7], nodes[5]);
            graph.AddEdge(nodes[8], nodes[5]);
            graph.AddEdge(nodes[9], nodes[6]);
            graph.AddEdge(nodes[9], nodes[3]);
            graph.AddEdge(nodes[9], nodes[4]);
            graph.AddEdge(nodes[10], nodes[8]);
            graph.AddEdge(nodes[11], nodes[8]);
            graph.AddEdge(nodes[11], nodes[9]);
        }