Modifier and Type | Method and Description |
---|---|
boolean |
contains(E element)
Checks whether this graph already contains the given element.
|
com.google.common.collect.ImmutableSet<E> |
getDirectParents(E element)
Returns the direct parents of the given
element . |
E |
getParentData(E element)
Get the parent data of the given element.
|
com.google.common.collect.ImmutableSet<E> |
getSubgraphContaining(E element)
Returns the set of all elements of the subgraph containing the given element.
|
com.google.common.collect.ImmutableSet<E> |
getSubgraphContaining(E element,
com.google.common.collect.ImmutableSet<E> endPoints)
Returns the set of all elements of the subgraph containing the given element and ending at the given
boundaries.
|
com.google.common.collect.ImmutableSet<E> |
getTreeFrom(E root)
Returns the tree starting from the given root element if it is contained in the graph.
|
com.google.common.collect.ImmutableSet<E> |
getTreeFrom(E root,
Set<E> endPoints)
Returns the tree starting from the given root element and ending at the given boundaries..
|
boolean |
hasChild(E parent,
E potentialChild)
Checks if the given element is a parent of the given potential child, directly or not.
|
static <E> ReadOnlyGraph<E> |
toReadOnlyGraph(Graph<E> graph)
Convert a graph to a read-only graph.
|
public static <E> ReadOnlyGraph<E> toReadOnlyGraph(Graph<E> graph)
E
- Kind of elements used as this graph's nodes.graph
- The writable graph to convert.public boolean contains(E element)
element
- Element we need to check.true
if this graph already contains the given elment, false
otherwise.public boolean hasChild(E parent, E potentialChild)
parent
- Element that could be a parent of potentialChild
.potentialChild
- The potential child of parent
.true
if parent
is an ancestor of potentialChild
.public com.google.common.collect.ImmutableSet<E> getDirectParents(E element)
element
.
Note that the returned set is an immutable view over a sub-graph of this graph.
element
- The element which parents we seek.element
.public E getParentData(E element)
null
. If the given element has no parents, then then this method will return
null
element
- Element we need the parent data of.E
if this element has a parent data, null
otherwise.public com.google.common.collect.ImmutableSet<E> getSubgraphContaining(E element)
Note that the returned set is an immutable view over a sub-graph of this graph.
element
- Element we need the subgraph of.public com.google.common.collect.ImmutableSet<E> getSubgraphContaining(E element, com.google.common.collect.ImmutableSet<E> endPoints)
Note that the returned set is an immutable view over a sub-graph of this graph.
element
- Element we need the subgraph of.endPoints
- Boundaries of the needed subgraph.public com.google.common.collect.ImmutableSet<E> getTreeFrom(E root)
Contrarily to getSubgraphContaining(Object)
, this will only iterate over the children (and
recursively) of the given node, without ever "going up" to parents of these children.
Note that the returned set is an immutable view over a sub-graph of this graph.
root
- The element we are to consider as the root of a tree.public com.google.common.collect.ImmutableSet<E> getTreeFrom(E root, Set<E> endPoints)
Contrarily to #getSubgraphContaining(Object, Set)
, this will only iterate over the children
(and recursively) of the given node, without ever "going up" to parents of these children.
Note that the returned set is an immutable view over a sub-graph of this graph.
root
- The element we are to consider as the root of a tree.endPoints
- Boundaries of the tree.
Copyright (c) 2006, 2014 Obeo and others. All rights reserved.