N
- node typepublic class SimpleMapGraph<N> extends Object implements MutableGraph<N,N,N,Void>, ShrinkableGraph<N,N>
This class provides maximum flexibility, but should only be used if performance is not a major concern.
SimpleGraph.NormalGraphView<N,G extends SimpleGraph<N>>
Constructor and Description |
---|
SimpleMapGraph()
|
SimpleMapGraph(Map<N,Collection<N>> structureMap)
Initializes a graph using the given adjacency structure, and adjacency information for
a single node is stored using
HashSet s. |
SimpleMapGraph(Map<N,Collection<N>> structureMap,
Supplier<? extends Collection<N>> adjCollSupplier)
Initializes a graph using the given adjacency structure, and adjacency information for
a single node is stored in data structures created via the provided supplier.
|
SimpleMapGraph(Supplier<? extends Collection<N>> adjCollSupplier)
Initializes a graph where the adjacency structure is stored using a
HashMap ,
and adjacency information for a single node is stored in data structures created via
the provided supplier. |
Modifier and Type | Method and Description |
---|---|
N |
addNode(N property)
Adds a new node to the graph.
|
Iterator<N> |
adjacentTargetsIterator(N node) |
Stream<N> |
adjacentTargetsStream(N node) |
N |
connect(N source,
N target,
Void property)
Inserts an edge in the graph.
|
Collection<? extends N> |
getAdjacentTargets(N node) |
Void |
getEdgeProperty(N edge)
Retrieves the property of a given edge.
|
N |
getNodeProperty(N node)
Retrieves the property of a given node.
|
Set<? extends N> |
getNodes()
Retrieves an (unmodifiable) collection of the nodes in this graph.
|
Collection<? extends N> |
getOutgoingEdges(N node)
Retrieves the outgoing edges of a given node.
|
N |
getTarget(N edge)
Retrieves, for a given edge, its target node.
|
Iterator<N> |
iterator() |
void |
removeEdge(N node,
N edge)
Removes an outgoing edge from the given node.
|
void |
removeNode(N node)
Removes a node from this graph.
|
void |
removeNode(N node,
N replacement)
Removes a node from this graph, and redirects all incoming edges to
the given replacement node (node that outgoing edges are still removed).
|
void |
setEdgeProperty(N edge,
Void property) |
void |
setNodeProperty(N node,
N property)
Deprecated.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addNode, connect
asNormalGraph, getGraphDOTHelper
nodeIDs, nodesStream, size
forEach, spliterator
getEdgesBetween, outgoingEdges, outgoingEdgesIterator, outgoingEdgesStream
adjacentTargets, createDynamicNodeMapping, createStaticNodeMapping, isConnected
public SimpleMapGraph()
public SimpleMapGraph(Supplier<? extends Collection<N>> adjCollSupplier)
HashMap
,
and adjacency information for a single node is stored in data structures created via
the provided supplier.adjCollSupplier
- the supplier for per-node adjacency collectionspublic SimpleMapGraph(Map<N,Collection<N>> structureMap)
HashSet
s.structureMap
- the map for the overall graph structurepublic SimpleMapGraph(Map<N,Collection<N>> structureMap, Supplier<? extends Collection<N>> adjCollSupplier)
structureMap
- the map for the overall graph structureadjCollSupplier
- the supplier for per-node adjacency collectionspublic Collection<? extends N> getOutgoingEdges(N node)
IndefiniteGraph
getOutgoingEdges
in interface IndefiniteGraph<N,N>
node
- the node.Collection
of all outgoing edges, or null
if
the node has no outgoing edges.public N getTarget(N edge)
IndefiniteGraph
getTarget
in interface IndefiniteGraph<N,N>
edge
- the edge.public Collection<? extends N> getAdjacentTargets(N node)
getAdjacentTargets
in interface IndefiniteGraph<N,N>
getAdjacentTargets
in interface IndefiniteSimpleGraph<N>
public Iterator<N> adjacentTargetsIterator(N node)
adjacentTargetsIterator
in interface IndefiniteGraph<N,N>
adjacentTargetsIterator
in interface IndefiniteSimpleGraph<N>
public Stream<N> adjacentTargetsStream(N node)
adjacentTargetsStream
in interface IndefiniteGraph<N,N>
adjacentTargetsStream
in interface IndefiniteSimpleGraph<N>
public Set<? extends N> getNodes()
SimpleGraph
getNodes
in interface SimpleGraph<N>
public N getNodeProperty(N node)
UniversalIndefiniteGraph
getNodeProperty
in interface UniversalIndefiniteGraph<N,N,N,Void>
node
- the nodepublic Void getEdgeProperty(N edge)
UniversalIndefiniteGraph
getEdgeProperty
in interface UniversalIndefiniteGraph<N,N,N,Void>
edge
- the edgepublic N addNode(N property)
MutableGraph
public N connect(N source, N target, Void property)
MutableGraph
@Deprecated public void setNodeProperty(N node, N property)
setNodeProperty
in interface MutableGraph<N,N,N,Void>
public void setEdgeProperty(N edge, Void property)
setEdgeProperty
in interface MutableGraph<N,N,N,Void>
public void removeNode(N node)
ShrinkableGraph
removeNode
in interface ShrinkableGraph<N,N>
node
- the node to remove.public void removeNode(N node, N replacement)
ShrinkableGraph
ShrinkableGraph.removeNode(Object)
.removeNode
in interface ShrinkableGraph<N,N>
node
- the node to removereplacement
- the replacement node for incoming edgespublic void removeEdge(N node, N edge)
ShrinkableGraph
removeEdge
in interface ShrinkableGraph<N,N>
node
- the nodeedge
- the edge to removeCopyright © 2015. All rights reserved.