public static EdgeCollection InEdgeTree(IBidirectionalVertexAndEdgeListGraph g, IEdge e, int maxDepth)
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     EdgeHeightFirstSearchAlgorithm algorithm = new EdgeHeightFirstSearchAlgorithm(g);
     algorithm.BackEdge += new EdgeEventHandler(null, (IntPtr) dfs_BackEdge);
     EdgeRecorderVisitor visitor = new EdgeRecorderVisitor();
     visitor.Edges.Add(e);
     algorithm.DiscoverTreeEdge += new EdgeEdgeEventHandler(visitor, (IntPtr) this.RecordTarget);
     algorithm.MaxDepth = maxDepth;
     algorithm.Initialize();
     algorithm.Visit(e, 0);
     return visitor.Edges;
 }
        /// <summary>
        /// Records all the edges that are part of the subtree of v
        /// </summary>
        /// <param name="g">visited graph</param>
        /// <param name="e">root edge</param>
        /// <param name="maxDepth">maximum expolration depth</param>
        /// <returns></returns>
        public static EdgeCollection OutEdgeTree(
            IEdgeListAndIncidenceGraph g,
            IEdge e,
            int maxDepth
            )
        {
            if (g==null)
                throw new ArgumentNullException("g");
            if (e==null)
                throw new ArgumentNullException("e");

            EdgeDepthFirstSearchAlgorithm dfs = new EdgeDepthFirstSearchAlgorithm(g);
            dfs.BackEdge +=new EdgeEventHandler(dfs_BackEdge);
            EdgeRecorderVisitor vis =new EdgeRecorderVisitor();
            vis.Edges.Add(e);

            dfs.DiscoverTreeEdge +=new EdgeEdgeEventHandler(vis.RecordTarget);

            dfs.MaxDepth = maxDepth;
            dfs.Initialize();
            dfs.Visit(e,0);

            return vis.Edges;
        }