Exemple #1
0
        protected List <StronglyCoherentComponent <int> > CreateStronglyCoherentComponents(List <TreeNodeModel <int, int> > transposedGraph)
        {
            var result = new List <StronglyCoherentComponent <int> >();

            _vertices.ForEach(v => v.Visited = false);
            _vertices = _vertices.OrderByDescending(x => x.ProcessingTime).ToList();

            _vertices.ForEach(v =>
            {
                if (!v.Visited)
                {
                    var localResult = new StronglyCoherentComponent <int>();

                    DFSBasedOnProcessingTime(transposedGraph, v, localResult);

                    result.Add(localResult);
                }
            });

            for (int i = 0; i < result.Count; i++)
            {
                result[i].ProcessingTime = i + 1;
            }

            return(result);
        }
Exemple #2
0
        protected void DFSBasedOnProcessingTime(List <TreeNodeModel <int, int> > graph, Vertex vertex, StronglyCoherentComponent <int> result)
        {
            vertex.Visited = true;

            var vertexGraph = graph.Where(x => x.Name == vertex.Name).FirstOrDefault();

            if (vertexGraph == null)
            {
                result.Vertices.Add(vertex);
                return;
            }

            vertexGraph.Neighbours.ForEach(neighbour =>
            {
                var neighVertex = _vertices.Where(x => x.Name == neighbour.Name).FirstOrDefault();
                if (!neighVertex.Visited)
                {
                    DFSBasedOnProcessingTime(graph, neighVertex, result);
                }
            });

            result.Vertices.Add(vertex);
        }