# Class: com.pnfsoftware.jeb.util.graph.Digraph

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: Digraph

Description: Create an empty directed graph.

## Method: canReach
- parameter: `from`, type: `com.pnfsoftware.jeb.util.graph.Digraph.V`
- parameter: `to`, type: `com.pnfsoftware.jeb.util.graph.Digraph.V`
- return type: `boolean`

Description: Determine whether a vertex can reach another vertex by following directed edges.
parameter: from: source vertex
parameter: to: destination vertex
return: true if `to` is reachable from `from`

## Method: computeEdgeBetweenness
- return type: `java.util.List<java.lang.Integer>`

Description: Compute the edge\-betweenness score of all edges of the graph using Girvan\-Newman. The scores are available through [E#getEdgeBetweennessScore()](E#getEdgeBetweennessScore()).
return: 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

## Method: copyOfEdges
- return type: `java.util.List<com.pnfsoftware.jeb.util.graph.Digraph.E>`

Description: Create a copy of the graph edges.
return: cloned edges in edge insertion order

## Method: copyOfVertices
- return type: `java.util.List<com.pnfsoftware.jeb.util.graph.Digraph.V>`

Description: Create a copy of the graph vertices.
return: cloned vertices in index order

## Method: done
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Verify the graph after an initial build step.
return: this graph

## Method: e
- parameter: `srcId`, type: `int`
- parameter: `dstId`, type: `int`
- parameter: `weight`, type: `java.lang.Double`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Add an edge to this graph, creating missing endpoint vertices if needed.
parameter: srcId: source vertex id
parameter: dstId: destination vertex id
parameter: weight: optional edge weight
return: this graph

## Method: e
- parameter: `srcId`, type: `int`
- parameter: `dstId`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Add an unweighted edge to this graph, creating missing endpoint vertices if needed.
parameter: srcId: source vertex id
parameter: dstId: destination vertex id
return: this graph

## Method: getEdge
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph.E`

Description: Get an edge by index.
parameter: index: edge index
return: the edge at that index

## Method: getEdge
- parameter: `srcId`, type: `int`
- parameter: `dstId`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph.E`

Description: Get an edge by source and destination vertex ids.
parameter: srcId: source vertex id
parameter: dstId: destination vertex id
return: the edge, or null if no such edge exists

## Method: getEdgeCount
- return type: `int`

Description: Get the number of edges.
return: the edge count

## Method: getEdgeIndexesByDescendingBetweenness
- return type: `java.util.List<java.lang.Integer>`

Description: Get edge indexes ordered by descending edge\-betweenness score.
return: a list of edge indexes ordered by descending score

## Method: getEdges
- return type: `java.util.List<com.pnfsoftware.jeb.util.graph.Digraph.E>`

Description: Get the graph edges.
return: the internal edge list in insertion order

## Method: getReachableVertices
- parameter: `fromId`, type: `int`
- return type: `java.util.Set<java.lang.Integer>`

Description: Get all vertices reachable from a vertex.
parameter: fromId: source vertex id
return: ids of vertices reachable from the source vertex

## Method: getVertex
- parameter: `id`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph.V`

Description: Get a vertex by id.
parameter: id: vertex id
return: the vertex, or null if no vertex has this id

## Method: getVertexByIndex
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph.V`

Description: Get a vertex by index.
parameter: index: vertex index
return: the vertex at that index

## Method: getVertexCount
- return type: `int`

Description: Get the number of vertices.
return: the vertex count

## Method: getVertexIndexesByDescendingCentrality
- return type: `java.util.List<java.lang.Integer>`

Description: Get vertex indexes ordered by descending vertex centrality score.
return: a list of vertex indexes ordered by descending score

## Method: getVertexLabel
- parameter: `id`, type: `int`
- return type: `java.lang.String`

Description: Get a vertex label by vertex id.
parameter: id: vertex id
return: the vertex label, or null if none was assigned

## Method: getVertices
- return type: `java.util.List<com.pnfsoftware.jeb.util.graph.Digraph.V>`

Description: Get the graph vertices.
return: the internal vertex list in index order

## Method: getWeaklyConnectedComponents
- return type: `java.util.List<com.pnfsoftware.jeb.util.graph.Digraph>`

Description: Split this graph into weakly connected components.
return: weakly connected component subgraphs; if this graph is already weakly connected, the         returned list contains this graph

## Method: isAdjacent
- parameter: `from`, type: `com.pnfsoftware.jeb.util.graph.Digraph.V`
- parameter: `to`, type: `com.pnfsoftware.jeb.util.graph.Digraph.V`
- return type: `boolean`

Description: Determine whether two vertices are directly connected by an edge.
parameter: from: source vertex
parameter: to: destination vertex
return: true if an edge exists from `from` to `to`

## Method: isWeaklyConnected
- return type: `boolean`

Description: Determine if this directed graph is weakly connected, that is, if the corresponding undirected graph is connected.
return: true if all vertices belong to a single weakly connected component

## Method: removeEdge
- parameter: `e`, type: `com.pnfsoftware.jeb.util.graph.Digraph.E`

Description: Remove an edge.
parameter: e: edge to remove

## Method: removeEdge
- parameter: `index`, type: `int`

Description: Remove an edge by index.
parameter: index: edge index

## Method: removeVertex
- parameter: `v`, type: `com.pnfsoftware.jeb.util.graph.Digraph.V`
- parameter: `reconnectEdges`, type: `boolean`

Description: Remove a vertex and all incident edges.
parameter: v: vertex to remove
parameter: reconnectEdges: true to connect each predecessor of the removed vertex to each of its            successors

## Method: resetEdgeBetweennessScores

Description: Reset edge\-betweenness and vertex centrality scores to zero.

## Method: setVertexLabel
- parameter: `id`, type: `int`
- parameter: `label`, type: `java.lang.String`

Description: Set a vertex label by vertex id.
parameter: id: vertex id
parameter: label: vertex label, or null to clear it

## Method: setVertexLabels
- parameter: `idLabels`, type: `java.lang.Object[]`

Description: Set multiple vertex labels. 

 Arguments are read as `Integer, String` pairs. Pairs whose values do not match those types are ignored.
parameter: idLabels: alternating vertex ids and labels

## Method: toString
- return type: `java.lang.String`


## Method: v
- parameter: `id`, type: `int`
- parameter: `weight`, type: `java.lang.Double`
- parameter: `label`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Add a vertex to this graph.
parameter: id: vertex id
parameter: weight: optional vertex weight
parameter: label: optional vertex label
return: this graph

## Method: v
- parameter: `id`, type: `int`
- parameter: `weight`, type: `java.lang.Double`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Add a vertex to this graph.
parameter: id: vertex id
parameter: weight: optional vertex weight
return: this graph

## Method: v
- parameter: `id`, type: `int`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Add a vertex to this graph.
parameter: id: vertex id
return: this graph

## Static Method: create
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Create an empty directed graph.
return: an empty directed graph

## Static Method: load
- parameter: `file`, type: `java.io.File`
- return type: `com.pnfsoftware.jeb.util.graph.Digraph`

Description: Load a graph from a text file.
parameter: file: graph definition file
return: the loaded graph
throws: if the file cannot be read

