Exemple #1
0
    private void BuildGraph()
    {
        GraphNode nodeR = new GraphNode('r');
        GraphNode nodeS = new GraphNode('s');
        GraphNode nodeT = new GraphNode('t');
        GraphNode nodeU = new GraphNode('u');

        GraphNode nodeV = new GraphNode('v');
        GraphNode nodeW = new GraphNode('w');
        GraphNode nodeX = new GraphNode('x');
        GraphNode nodeY = new GraphNode('y');

        nodeR.AddAdj(nodeS);
        nodeR.AddAdj(nodeV);

        nodeS.AddAdj(nodeR);
        nodeS.AddAdj(nodeW);

        nodeT.AddAdj(nodeW);
        nodeT.AddAdj(nodeX);
        nodeT.AddAdj(nodeU);

        nodeU.AddAdj(nodeT);
        nodeU.AddAdj(nodeX);
        nodeU.AddAdj(nodeY);

        nodeV.AddAdj(nodeR);

        nodeW.AddAdj(nodeS);
        nodeW.AddAdj(nodeT);
        nodeW.AddAdj(nodeX);

        nodeX.AddAdj(nodeW);
        nodeX.AddAdj(nodeT);
        nodeX.AddAdj(nodeU);
        nodeX.AddAdj(nodeY);

        nodeY.AddAdj(nodeX);
        nodeY.AddAdj(nodeU);

        GraphNodeList.Add(nodeR);
        GraphNodeList.Add(nodeS);
        GraphNodeList.Add(nodeT);
        GraphNodeList.Add(nodeU);
        GraphNodeList.Add(nodeV);
        GraphNodeList.Add(nodeW);
        GraphNodeList.Add(nodeX);
        GraphNodeList.Add(nodeY);

        DFS(GraphNodeList);

        //PrintPath(GraphNodeList, nodeS, nodeY);
    }