Package com.google.common.graph
Class AbstractNetwork<N,E>
- java.lang.Object
-
- com.google.common.graph.AbstractNetwork<N,E>
-
- Type Parameters:
N
- Node parameter typeE
- Edge parameter type
- All Implemented Interfaces:
Network<N,E>
- Direct Known Subclasses:
ImmutableNetwork
@Beta public abstract class AbstractNetwork<N,E> extends java.lang.Object implements Network<N,E>
This class provides a skeletal implementation ofNetwork
. It is recommended to extend this class rather than implementNetwork
directly.- Since:
- 20.0
-
-
Constructor Summary
Constructors Constructor Description AbstractNetwork()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<E>
adjacentEdges(java.lang.Object edge)
Returns the edges which have anincident node
in common withedge
.Graph<N>
asGraph()
Returns a live view of this network as aGraph
.int
degree(java.lang.Object node)
Returns the count ofnode
'sincident edges
, counting self-loops twice (equivalently, the number of times an edge touchesnode
).int
inDegree(java.lang.Object node)
Returns the count ofnode
'sincoming edges
in a directed network.int
outDegree(java.lang.Object node)
Returns the count ofnode
'soutgoing edges
in a directed network.java.lang.String
toString()
Returns a string representation of this network.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.graph.Network
adjacentNodes, allowsParallelEdges, allowsSelfLoops, edgeOrder, edges, edgesConnecting, equals, hashCode, incidentEdges, incidentNodes, inEdges, isDirected, nodeOrder, nodes, outEdges, predecessors, successors
-
-
-
-
Method Detail
-
asGraph
public Graph<N> asGraph()
Description copied from interface:Network
Returns a live view of this network as aGraph
. The resultingGraph
will have an edge connecting node A to node B if thisNetwork
has an edge connecting A to B.If this network
allows parallel edges
, parallel edges will be treated as if collapsed into a single edge. For example, theNetwork.degree(Object)
of a node in theGraph
view may be less than the degree of the same node in thisNetwork
.
-
degree
public int degree(java.lang.Object node)
Description copied from interface:Network
Returns the count ofnode
'sincident edges
, counting self-loops twice (equivalently, the number of times an edge touchesnode
).For directed networks, this is equal to
inDegree(node) + outDegree(node)
.For undirected networks, this is equal to
incidentEdges(node).size()
+ (number of self-loops incident tonode
).If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
.
-
inDegree
public int inDegree(java.lang.Object node)
Description copied from interface:Network
Returns the count ofnode
'sincoming edges
in a directed network. In an undirected network, returns theNetwork.degree(Object)
.If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
.
-
outDegree
public int outDegree(java.lang.Object node)
Description copied from interface:Network
Returns the count ofnode
'soutgoing edges
in a directed network. In an undirected network, returns theNetwork.degree(Object)
.If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
.
-
adjacentEdges
public java.util.Set<E> adjacentEdges(java.lang.Object edge)
Description copied from interface:Network
Returns the edges which have anincident node
in common withedge
. An edge is not considered adjacent to itself.- Specified by:
adjacentEdges
in interfaceNetwork<N,E>
-
toString
public java.lang.String toString()
Returns a string representation of this network.- Overrides:
toString
in classjava.lang.Object
-
-