Class DirectedGraph


  • public class DirectedGraph
    extends java.lang.Object
    DirectedGraph
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectedGraph​(com.fasterxml.jackson.databind.JsonNode jsonGraph)
      Initializes a DirectedGraph from the specified JsonNode.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getId​(java.lang.Integer index)
      Retrieve the id mapping the index
      int getVertices()
      Returns the number of vertices in this DirectedGraph.
      int indegree​(int vertices)
      Returns the number of directed edges incident to vertex vertices.
      DirectedGraph reverse()
      Returns the reverse of the DirectedGraph.
      java.lang.String toString()
      Returns a string representation of the graph.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DirectedGraph

        public DirectedGraph​(com.fasterxml.jackson.databind.JsonNode jsonGraph)
        Initializes a DirectedGraph from the specified JsonNode.
        Parameters:
        jsonGraph -
        Throws:
        java.lang.IndexOutOfBoundsException - if the endpoints of any edge are not in prescribed range
        java.lang.IllegalArgumentException - if the number of vertices or edges is negative
    • Method Detail

      • getVertices

        public int getVertices()
        Returns the number of vertices in this DirectedGraph.
        Returns:
        the number of vertices in this DirectedGraph
      • indegree

        public int indegree​(int vertices)
        Returns the number of directed edges incident to vertex vertices. This is known as the indegree of vertex vertices.
        Parameters:
        vertices - the vertex
        Returns:
        the indegree of vertex vertices
        Throws:
        java.lang.IndexOutOfBoundsException - unless 0 <= v < vertices
      • reverse

        public DirectedGraph reverse()
        Returns the reverse of the DirectedGraph.
        Returns:
        the reverse of the DirectedGraph (child[parents] to parent[children])
      • toString

        public java.lang.String toString()
        Returns a string representation of the graph.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the number of vertice, adjacency lists
      • getId

        public java.lang.String getId​(java.lang.Integer index)
        Retrieve the id mapping the index
        Parameters:
        index - index
        Returns:
        id