Class Digraph

java.lang.Object
com.pnfsoftware.jeb.util.graph.Digraph

public class Digraph extends Object
A directed graph object, cyclic or acyclic. Self-loops (x>x) are also allowed. Duplicate edges are not allowed, e.g. if an edge x>y exists, another edge x>y cannot be added (a way to represent this information is to specify an edge weight).
  • Constructor Details

    • Digraph

      public Digraph()
  • Method Details

    • create

      public static Digraph create()
    • copyOfVertices

      public List<Digraph.V> copyOfVertices()
    • copyOfEdges

      public List<Digraph.E> copyOfEdges()
    • getVertexCount

      public int getVertexCount()
    • getVertices

      public List<Digraph.V> getVertices()
    • getVertex

      public Digraph.V getVertex(int id)
    • getVertexByIndex

      public Digraph.V getVertexByIndex(int index)
    • getVertexLabel

      public String getVertexLabel(int id)
    • setVertexLabel

      public void setVertexLabel(int id, String label)
    • setVertexLabels

      public void setVertexLabels(Object... idLabels)
    • removeVertex

      public void removeVertex(Digraph.V v, boolean reconnectEdges)
    • getEdgeCount

      public int getEdgeCount()
    • getEdges

      public List<Digraph.E> getEdges()
    • getEdge

      public Digraph.E getEdge(int index)
    • removeEdge

      public void removeEdge(Digraph.E e)
    • removeEdge

      public void removeEdge(int index)
    • getEdge

      public Digraph.E getEdge(int srcId, int dstId)
    • v

      public Digraph v(int id, Double weight, String label)
      Add a vertex to this graph.
      Parameters:
      id -
      weight - optional
      label - optional
      Returns:
    • v

      public Digraph v(int id, Double weight)
    • v

      public Digraph v(int id)
    • e

      public Digraph e(int srcId, int dstId, Double weight)
    • e

      public Digraph e(int srcId, int dstId)
    • done

      public Digraph done()
      Clients can call this method to indicate that the initial graph is built: after calling this method, additions of vertices or edges is forbidden. However, removal of edges is allowed.
    • resetEdgeBetweennessScores

      public void resetEdgeBetweennessScores()
    • computeEdgeBetweenness

      public List<Integer> computeEdgeBetweenness()
      Compute the edge-betweenness score of all edges of the graph using Girvan-Newman. The scores are placed in Digraph.E.ebscore.
      Returns:
      a list of edge indexes ordered by descending order of edge-betweenness score; e.g., if the first element of the list is 2, it means that the third registered edge (getEdge(2)) is the one with the highest EB score
    • getEdgeIndexesByDescendingBetweenness

      public List<Integer> getEdgeIndexesByDescendingBetweenness()
    • getVertexIndexesByDescendingCentrality

      public List<Integer> getVertexIndexesByDescendingCentrality()
    • isWeaklyConnected

      public boolean isWeaklyConnected()
      Determine if this directed graph is weakly connected, that is, if the similar undirected graph is connected.
      Returns:
    • getWeaklyConnectedComponents

      public List<Digraph> getWeaklyConnectedComponents()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isAdjacent

      public boolean isAdjacent(Digraph.V from, Digraph.V to)
    • canReach

      public boolean canReach(Digraph.V from, Digraph.V to)
    • getReachableVertices

      public Set<Integer> getReachableVertices(int fromId)
    • load

      public static Digraph load(File file) throws IOException
      Parameters:
      file -
      Returns:
      Throws:
      IOException