public class Networks
extends java.lang.Object
Network
instances that are directed.Modifier and Type | Class and Description |
---|---|
static class |
Networks.TypeSafeNodeFunction<NodeT,T extends NodeT>
An abstract class that can be extended to apply a function in a type safe manner.
|
Modifier and Type | Method and Description |
---|---|
static <NodeT,EdgeT> |
allPathsFromRootsToLeaves(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network)
Returns a list of all distinct paths from roots of the network to leaves.
|
static <NodeT,EdgeT> |
reachableNodes(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network,
java.util.Set<NodeT> startNodes,
java.util.Set<NodeT> endNodes)
Returns the set of nodes that are reachable from
startNodes up to and including endNodes . |
static <NodeT,EdgeT> |
replaceDirectedNetworkNodes(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.MutableNetwork<NodeT,EdgeT> network,
java.util.function.Function<NodeT,NodeT> function)
Applies the
function to all nodes within the network . |
static <NodeT,EdgeT> |
toDot(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network) |
static <NodeT> java.lang.Iterable<NodeT> |
topologicalOrder(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,?> network)
Return a set of nodes in sorted topological order.
|
static <NodeT,EdgeT> |
topologicalOrder(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network,
java.util.Comparator<NodeT> nodeOrder)
Return a set of nodes in sorted topological order.
|
public static <NodeT,EdgeT> void replaceDirectedNetworkNodes(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.MutableNetwork<NodeT,EdgeT> network, java.util.function.Function<NodeT,NodeT> function)
function
to all nodes within the network
. Replaces any node which
is not Object.equals(Object)
to the original node, maintaining all existing edges between
nodes.public static <NodeT,EdgeT> java.util.Set<NodeT> reachableNodes(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network, java.util.Set<NodeT> startNodes, java.util.Set<NodeT> endNodes)
startNodes
up to and including endNodes
. Node B is defined as reachable from node A if there exists a path (a sequence of
adjacent outgoing edges) starting at node A and ending at node B which does not pass through
any node in endNodes
. Note that a node is always reachable from itself via a
zero-length path.
This is a "snapshot" based on the current topology of the network
, rather than a
live view of the set of nodes reachable from node
. In other words, the returned Set
will not be updated after modifications to the network
.
public static <NodeT> java.lang.Iterable<NodeT> topologicalOrder(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,?> network)
Note that back edges within directed graphs are "broken" returning a topological order for a directed acyclic network which approximates the original network.
Nodes will be considered in the order specified by the Network's
Network.nodeOrder()
.
public static <NodeT,EdgeT> java.lang.Iterable<NodeT> topologicalOrder(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network, java.util.Comparator<NodeT> nodeOrder)
Note that back edges within directed graphs are "broken" returning a topological order for a directed acyclic network which approximates the original network.
Nodes will be considered in the order specified by the sorted ElementOrder
created with the provided comparator.
public static <NodeT,EdgeT> java.lang.String toDot(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network)
public static <NodeT,EdgeT> java.util.List<java.util.List<NodeT>> allPathsFromRootsToLeaves(org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.graph.Network<NodeT,EdgeT> network)