Exemplo n.º 1
0
        private static IPathToNode TestTwo()
        {
            INode node_A = new Node("A");
            INode node_B = new Node("B");
            INode node_C = new Node("C");
            INode node_D = new Node("D");
            INode node_E = new Node("E");
            INode node_F = new Node("F");
            INode node_G = new Node("G");
            INode node_H = new Node("H");
            INode node_I = new Node("I");
            INode node_J = new Node("J");
            INode node_K = new Node("K");
            INode node_L = new Node("L");
            INode node_M = new Node("M");
            INode node_N = new Node("N");
            INode node_O = new Node("O");
            INode node_P = new Node("P");
            INode node_Q = new Node("Q");
            INode node_R = new Node("R");

            IEdge edge_AB = new Edge(node_A, node_B, 10);
            IEdge edge_AD = new Edge(node_A, node_D, 5);
            IEdge edge_AE = new Edge(node_A, node_E, 7);
            IEdge edge_BC = new Edge(node_B, node_C, 1);
            IEdge edge_BF = new Edge(node_B, node_F, 4);
            IEdge edge_CF = new Edge(node_C, node_F, 16);
            IEdge edge_DG = new Edge(node_D, node_G, 10);
            IEdge edge_EI = new Edge(node_E, node_I, 4);
            IEdge edge_FH = new Edge(node_F, node_H, 8);
            IEdge edge_GH = new Edge(node_G, node_H, 1);
            IEdge edge_GJ = new Edge(node_G, node_J, 7);
            IEdge edge_HK = new Edge(node_H, node_K, 3);
            IEdge edge_IK = new Edge(node_I, node_K, 2);
            IEdge edge_JK = new Edge(node_J, node_K, 2);
            IEdge edge_JM = new Edge(node_J, node_M, 11);
            IEdge edge_KL = new Edge(node_K, node_L, 5);
            IEdge edge_LO = new Edge(node_L, node_O, 7);
            IEdge edge_MP = new Edge(node_M, node_P, 2);
            IEdge edge_MQ = new Edge(node_M, node_Q, 3);
            IEdge edge_NO = new Edge(node_N, node_O, 3);
            IEdge edge_NQ = new Edge(node_N, node_Q, 8);
            IEdge edge_OR = new Edge(node_O, node_R, 4);
            IEdge edge_PQ = new Edge(node_P, node_Q, 6);
            IEdge edge_QR = new Edge(node_Q, node_R, 10);

            ICollection <IEdge> pathEdges = new List <IEdge>()
            {
                edge_AB, edge_AD, edge_AE, edge_BC, edge_BF, edge_CF, edge_DG,
                edge_EI, edge_FH, edge_GH, edge_HK, edge_IK, edge_JK, edge_JM,
                edge_KL, edge_LO, edge_MP, edge_MQ, edge_NO, edge_NQ, edge_OR,
                edge_PQ, edge_QR
            };

            PathGraph graph = new PathGraph(pathEdges);

            IPathToNode result = graph.FindShortestPathWithDijkstra((IPathToNode)node_A, (IPathToNode)node_Q);

            return(result);
        }
Exemplo n.º 2
0
        private static IPathToNode TestOne()
        {
            INode node_A = new Node("A");
            INode node_B = new Node("B");
            INode node_C = new Node("C");
            INode node_D = new Node("D");
            INode node_E = new Node("E");
            INode node_Z = new Node("Z");

            IEdge edge_AB = new Edge(node_A, node_B, 4);
            IEdge edge_AC = new Edge(node_A, node_C, 2);
            IEdge edge_BC = new Edge(node_B, node_C, 1);
            IEdge edge_BD = new Edge(node_B, node_D, 5);
            IEdge edge_CD = new Edge(node_C, node_D, 8);
            IEdge edge_CE = new Edge(node_C, node_E, 10);
            IEdge edge_DE = new Edge(node_D, node_E, 2);
            IEdge edge_DZ = new Edge(node_D, node_Z, 6);
            IEdge edge_EZ = new Edge(node_E, node_Z, 3);
            ICollection <IEdge> pathEdges = new List <IEdge>()
            {
                edge_AB, edge_AC, edge_BC, edge_BD, edge_CD, edge_CE, edge_DE, edge_DZ, edge_EZ
            };

            PathGraph graph = new PathGraph(pathEdges);

            IPathToNode result = graph.FindShortestPathWithDijkstra((IPathToNode)node_A, (IPathToNode)node_Z);

            return(result);
        }