Esempio n. 1
0
        /**
         * Returns a list of vertices that are the direct successors of a specified vertex. If the graph
         * is a multigraph vertices may appear more than once in the returned list.
         *
         * <p>
         * The method uses {@link Graph#outgoingEdgesOf(Object)} to traverse the graph.
         *
         * @param g the graph to look for successors in
         * @param vertex the vertex to get the successors of
         * @param <V> the graph vertex type
         * @param <E> the graph edge type
         *
         * @return a list of the vertices that are the direct successors of the specified vertex.
         */
        public static List <V> successorListOf <V, E>(Graph <V, E> g, V vertex)
        {
            List <V>    successors = new List <V>();
            HashSet <E> edges      = g.outgoingEdgesOf(vertex);

            foreach (E e in edges)
            {
                successors.Add(getOppositeVertex(g, e, vertex));
            }

            return(successors);
        }
Esempio n. 2
0
 /**
  * Check if a vertex has any direct successors.
  *
  * @param graph the graph to look for successors
  * @param vertex the vertex to look for successors
  * @param <V> the graph vertex type
  * @param <E> the graph edge type
  *
  * @return true if the vertex has any successors, false otherwise
  */
 public static bool vertexHasSuccessors <V, E>(Graph <V, E> graph, V vertex)
 {
     return(graph.outgoingEdgesOf(vertex).Count != 0);
 }