예제 #1
0
        /// <summary>
        /// walk through graph from fromVtx, in direction of eid, until we hit the next junction vertex
        /// </summary>
        public static List <int> WalkToNextNonRegularVtx(DGraph2 graph, int fromVtx, int eid)
        {
            List <int> path = new List <int>();

            path.Add(fromVtx);
            int  cur_vid   = fromVtx;
            int  cur_eid   = eid;
            bool bContinue = true;

            while (bContinue)
            {
                Index2i next     = DGraph2Util.NextEdgeAndVtx(cur_eid, cur_vid, graph);
                int     next_eid = next.a;
                int     next_vtx = next.b;
                if (next_eid == int.MaxValue)
                {
                    if (graph.IsRegularVertex(next_vtx) == false)
                    {
                        path.Add(next_vtx);
                        bContinue = false;
                    }
                    else
                    {
                        throw new Exception("WalkToNextNonRegularVtx: have no next edge but vtx is regular - how?");
                    }
                }
                else
                {
                    path.Add(next_vtx);
                    cur_vid = next_vtx;
                    cur_eid = next_eid;
                }
            }
            return(path);
        }