コード例 #1
0
        private static void Build3ComponentsUndirectedGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);
            graph.AddVertex(7);
            graph.AddVertex(8);
            graph.AddVertex(9);
            graph.AddVertex(10);
            graph.AddVertex(11);
            graph.AddVertex(12);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next);
            graph.AddEdge(2, 4, edgeId.Next);
            graph.AddEdge(4, 5, edgeId.Next);
            graph.AddEdge(5, 1, edgeId.Next);
            graph.AddEdge(3, 1, edgeId.Next);

            graph.AddEdge(6, 7, edgeId.Next);
            graph.AddEdge(7, 8, edgeId.Next);
            graph.AddEdge(8, 6, edgeId.Next);

            graph.AddEdge(9, 10, edgeId.Next);
            graph.AddEdge(10, 11, edgeId.Next);
            graph.AddEdge(11, 12, edgeId.Next);
            graph.AddEdge(12, 9, edgeId.Next);
        }
コード例 #2
0
        private static void BuildDirectedAcyclicGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);
            graph.AddVertex(7);
            graph.AddVertex(8);
            graph.AddVertex(9);
            graph.AddVertex(10);
            graph.AddVertex(11);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 7, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 11, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 9, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 3, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(3, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(5, 2, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 5, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 6, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 7, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(9, 10, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(10, 11, edgeId.Next, EdgeDirectionType.Directed);
        }
コード例 #3
0
        private static void BuildGraph1(IGraph graph)
        {
            //var vertextId = new IntIdGenerator();
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);
            graph.AddVertex(7);
            graph.AddVertex(8);
            graph.AddVertex(9);
            graph.AddVertex(10);
            graph.AddVertex(11);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next);
            graph.AddEdge(1, 3, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 5, edgeId.Next);
            graph.AddEdge(5, 8, edgeId.Next);
            graph.AddEdge(5, 9, edgeId.Next);
            graph.AddEdge(8, 10, edgeId.Next);
            graph.AddEdge(8, 11, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 9, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 6, edgeId.Next);
            graph.AddEdge(4, 8, edgeId.Next);
            graph.AddEdge(3, 7, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(7, 8, edgeId.Next, EdgeDirectionType.Directed);
        }
コード例 #4
0
        private static void BuildDirectedCyclicGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 3, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(3, 1, edgeId.Next, EdgeDirectionType.Directed);
        }
コード例 #5
0
        private static void BuildGraph2(IGraph graph)
        {
            //var vertextId = new IntIdGenerator();
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next, 2);
            graph.AddEdge(1, 4, edgeId.Next, 4);
            graph.AddEdge(1, 5, edgeId.Next, 5);
            graph.AddEdge(1, 6, edgeId.Next, 4);
            graph.AddEdge(2, 4, edgeId.Next, 1);
            graph.AddEdge(2, 5, edgeId.Next, 2);
            graph.AddEdge(2, 3, edgeId.Next, 4);
            graph.AddEdge(6, 3, edgeId.Next, 1);
        }