Exemplo n.º 1
0
        public void execute(Graph graph, Node node)
        {
            //On marque le noeud
                node.markNode();

                //On copie les caractéristiques du noeud dans un nouveau noeud
                 Node n = new Node(node.getIndex(), node.getName());

                //On ajoute ce dernier au graphe
                 depthFirstTree.addNode(n);

                //Pour chaque arc partant du noeud :
                foreach (Arc a in node.getEgressArc())
                {
                    if (a.getEdge().getNodeState() == false)
                    {
                        Node e = new Node(a.getEdge().getIndex(), a.getEdge().getName());
                        depthFirstTree.addArc(new Arc(a.getCost(), n, e));
                        execute(graph, a.getEdge());
                    }
                }
        }
Exemplo n.º 2
0
        //Parcours en profondeur du graph à partir du noeud passé en paramètre
        public void executeDFS(Graph graph, Node origine)
        {
            origine.markNode();

            foreach (Arc a in origine.getEgressArc())
            {

                if (a.getEdge().getNodeState() == false)
                {
                    depthFirstPath.Add(a.getEdge(), a.getOrigin());
                    executeDFS(graph, a.getEdge());
                }
            }
        }