T - The type of the node.public interface Graph<T extends Node>
extends java.lang.Iterable<T>
| Modifier and Type | Field and Description |
|---|---|
static int |
IGNORE_SELFLOOPS
When inverting a graph, ignore self loops (don't add and don't remove)
|
static int |
INVERT_SELFLOOPS
When inverting a graph, deal with self loops like ordinary edges (add if not present and remove if present)
|
static int |
REMOVE_SELFLOOPS
When inverting a graph, simple remove self loops, but don't add new ones.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Edge<T> edge)
Adds the given edge to this graph.
|
boolean |
add(T node)
Adds the given node to this graph.
|
boolean |
areAdjacent(T a,
T b)
Returns "true" iff the two nodes are connected by a directed edge
from a to b or an undirected edge.
|
boolean |
contains(java.lang.Object obj)
Returns "true" when this graph contains the given
node or edge.
|
boolean |
existsDirectedPath(T node1,
T node2)
Checks whether there is a (directed) path from node1 to node2.
|
Matrix |
getAdjancyMatrix()
Returns the adjacency matrix of this graph (the order
of the nodes is the same as returned by "iterator()").
|
java.util.Collection<T> |
getChildren(Node node)
Returns the set of children (node connected via an undirected edge or a directed edge
where the given node is the parent) of the given node.
|
Graph<T> |
getComplementGraph(int selfloops)
Returns the complement graph of this graph, i.e.
|
Edge<T> |
getEdge(T a,
T b)
Returns the corresponding edge (a,b) if a and b are adjacent.
|
java.util.Collection<? extends Edge<? extends T>> |
getEdges()
Returns the edges of this graph.
|
java.util.Collection<T> |
getNeighbors(T node)
Returns the set of neighbors of the given node.
|
java.util.Collection<T> |
getNodes()
Returns the nodes of this graph.
|
int |
getNumberOfNodes()
Returns the number of nodes in this graph.
|
java.util.Collection<T> |
getParents(Node node)
Returns the set of parents (node connected via an undirected edge or a directed edge
where the given node is the child) of the given node.
|
Graph<T> |
getRestriction(java.util.Collection<T> nodes)
Returns copy of this graph consisting only of the given
nodes and all corresponding edges.
|
java.util.Collection<java.util.Collection<T>> |
getStronglyConnectedComponents()
Returns the strongly connected components of this graph.
|
java.util.Collection<Graph<T>> |
getSubgraphs()
Returns the set of sub graphs of this graph.
|
boolean |
hasSelfLoops()
Returns "true" iff the graph has a self loop (an edge from a node to itself).
|
boolean |
isWeightedGraph()
Checks whether this graph only contains weighted edges.
|
java.util.Iterator<T> |
iterator() |
java.lang.String |
toString() |
static final int IGNORE_SELFLOOPS
static final int INVERT_SELFLOOPS
static final int REMOVE_SELFLOOPS
boolean add(T node)
node - some node.boolean add(Edge<T> edge)
edge - some edge.java.util.Collection<T> getNodes()
int getNumberOfNodes()
boolean areAdjacent(T a, T b)
a - some nodeb - some nodeEdge<T> getEdge(T a, T b)
a - some nodeb - some nodejava.util.Collection<? extends Edge<? extends T>> getEdges()
java.util.Iterator<T> iterator()
boolean contains(java.lang.Object obj)
obj - an objectjava.util.Collection<T> getChildren(Node node)
node - some node (must be in the graph).java.util.Collection<T> getParents(Node node)
node - some node (must be in the graph).boolean existsDirectedPath(T node1, T node2)
node1 - some node.node2 - some node.java.util.Collection<T> getNeighbors(T node)
node - some node (must be in the graph).Matrix getAdjancyMatrix()
Graph<T> getComplementGraph(int selfloops)
selfloops - Indicates how to deal with selfloops:java.util.Collection<java.util.Collection<T>> getStronglyConnectedComponents()
java.util.Collection<Graph<T>> getSubgraphs()
Graph<T> getRestriction(java.util.Collection<T> nodes)
nodes - a set of nodesboolean hasSelfLoops()
boolean isWeightedGraph()
java.lang.String toString()
toString in class java.lang.Object