Ejemplo n.º 1
0
        private void ConstructGraph(string graph)
        {
            IEnumerable <string> edgeList = Validate(graph);

            foreach (string edgeString in edgeList)
            {
                _graph.AddEdge(edgeString[0], edgeString[1], Convert.ToInt32(edgeString[2].ToString()));
            }
        }
Ejemplo n.º 2
0
        private void RemoveCycles(AbstractDiGraph <TNode> graph, TNode startNode)
        {
            List <DepthFirstSearchEdge <TNode> > dfsEdges   = DFSAlgorithm.TraverseGraph(graph, startNode);
            List <DepthFirstSearchEdge <TNode> > _backedges =
                dfsEdges.Where(
                    x => x.EdgeType == DepthFirstSearchEdgeType.BackEdge && x.DestinationNode.Equals(startNode))
                .ToList();

            _backedges.ForEach(x => dfsEdges.Remove(x));

            dfsEdges.ForEach(x => _cycleFreeGraph.AddEdge(x.SourceNode, x.DestinationNode, x.EdgeWeight));
        }