Esempio n. 1
0
        public static IEnumerable <string> Get_First_Mutual_Branch_Point_Backwards(string vertex, BidirectionalGraph <string, TaggedEdge <string, Tag> > graph)
        {
            Contract.Requires(graph != null);

            if (!graph.ContainsVertex(vertex))
            {
                yield break;
            }

            int inDegree = graph.InDegree(vertex);

            if (inDegree < 2)
            {
                yield break; // the provided vertex is not a mergePoint
            }

            if (inDegree == 2)
            {
                string s1 = graph.InEdge(vertex, 0).Source;
                string s2 = graph.InEdge(vertex, 1).Source;

                if (s1 != s2)
                {
                    HashSet <string> branchPoints1 = new HashSet <string>();
                    HashSet <string> branchPoints2 = new HashSet <string>();

                    foreach (string v in Get_First_Branch_Point_Backwards(s1, graph))
                    {
                        branchPoints1.Add(v);
                    }

                    foreach (string v in Get_First_Branch_Point_Backwards(s2, graph))
                    {
                        branchPoints2.Add(v);
                    }

                    foreach (string mutual in branchPoints1.Intersect(branchPoints2))
                    {
                        yield return(mutual);
                    }
                }
            }
            else
            {
                Console.WriteLine("WARNING: Get_First_Mutual_Branch_Point_Backwards: multiple merge points at this the provided vertex " + vertex);
            }
        }
Esempio n. 2
0
 public TEdge InEdge(TVertex v, int index) => _graph.InEdge(v, index);