public class DirectedWeightedGraph extends SNTGraph<SWCPoint,SWCWeightedEdge>
| Constructor and Description |
|---|
DirectedWeightedGraph()
Creates an empty DirectedWeightedGraph.
|
DirectedWeightedGraph(Collection<SWCPoint> nodes,
boolean assignDistancesToWeight)
Creates a DirectedWeightedGraph from a collection of reconstruction nodes.
|
DirectedWeightedGraph(Tree tree)
Creates a DirectedWeightedGraph from a Tree with edge weights corresponding
to inter-node distances.
|
DirectedWeightedGraph(Tree tree,
boolean assignDistancesToWeight)
Creates a DirectedWeightedGraph from a Tree, with the option to assign edge weights corresponding
to inter-node distances.
|
| Modifier and Type | Method and Description |
|---|---|
SWCPoint |
addVertex(double x,
double y,
double z) |
void |
assignEdgeWeightsEuclidean()
For all edges, sets the Euclidean distance between the source and target
vertex as the weight.
|
List<SWCPoint> |
getBPs()
Gets the branch points (junctions) of the graph.
|
org.jgrapht.traverse.BreadthFirstIterator<SWCPoint,SWCWeightedEdge> |
getBreadthFirstIterator()
Gets a
BreadthFirstIterator, using the graph root as start vertex. |
org.jgrapht.traverse.BreadthFirstIterator<SWCPoint,SWCWeightedEdge> |
getBreadthFirstIterator(SWCPoint startVertex)
Gets a
BreadthFirstIterator, using the specified start vertex. |
List<DirectedWeightedGraph> |
getComponents()
Return the connected components of this graph as a list of new
DirectedWeightedGraphs. |
org.jgrapht.traverse.DepthFirstIterator<SWCPoint,SWCWeightedEdge> |
getDepthFirstIterator()
Gets a
DepthFirstIterator, using the graph root as start vertex. |
org.jgrapht.traverse.DepthFirstIterator<SWCPoint,SWCWeightedEdge> |
getDepthFirstIterator(SWCPoint startVertex)
Gets a
DepthFirstIterator, using the specified start vertex. |
Path |
getLongestPath(boolean useDirected)
Return the sequence of nodes representing the
longest shortest-path
in the graph, as a
Path. |
Deque<SWCPoint> |
getLongestPathVertices(boolean useDirected)
Return the sequence of nodes representing the
longest shortest-path
in the graph, as a
Deque. |
NodeStatistics<SWCPoint> |
getNodeStatistics()
Gets a NodeStatistics instance for the vertex set
|
NodeStatistics<SWCPoint> |
getNodeStatistics(String type)
Gets a NodeStatistics instance for the nodes in the vertex set of the specified type
|
SWCPoint |
getRoot()
Gets the root of this graph.
|
Path |
getShortestPath(SWCPoint v1,
SWCPoint v2)
Gets the shortest path between source and target vertex as a
Path object. |
Deque<SWCPoint> |
getShortestPathVertices(SWCPoint v1,
SWCPoint v2)
Gets the shortest path between source and target vertex as a
Deque of SWCPoint objects. |
DirectedWeightedGraph |
getSimplifiedGraph()
Returns a simplified graph in which slab nodes are removed and the graph
is represented only by root, branch nodes and leaves.
|
DirectedWeightedSubgraph |
getSubgraph(Set<SWCPoint> nodeSubset)
Returns the subgraph defined by the supplied subset of vertices, including their edges.
|
List<SWCPoint> |
getTips()
Gets the end points (tips) of the graph.
|
Tree |
getTree()
Returns a new tree associated with this graph, using the current state of the
graph to build the tree.
|
Tree |
getTree(boolean createNewTree)
Returns a tree associated with this graph.
|
List<Tree> |
getTrees()
Return the connected components of this graph as a list of
Trees |
Tree |
getTreeWithSamePathStructure()
Attempt to build a new Tree with the same
Path hierarchy as the source Tree. |
void |
scale(double xScale,
double yScale,
double zScale,
boolean updateEdgeWeightsEuclidean)
Scales the point coordinates of each vertex by the specified factors.
|
void |
setRoot(SWCPoint newRoot)
Sets the root of the tree.
|
Window |
show()
Displays this graph in a new instance of SNT's "Dendrogram Viewer".
|
double |
sumEdgeWeights()
Gets the sum of all edge weights.
|
void |
updateVertexProperties()
Re-assigns a unique Integer identifier to each vertex based on visit order
during Depth First Search.
|
Set<SWCPoint> |
vertexSet(char lr)
Returns the subset of vertices contained in the given hemisphere
|
applyEdges, applyVertices, filterEdges, filterVertices, getEdgeColor, getEdgeColorRGBMap, getVertexColor, getVertexColorRGBMap, getVertexValue, getVertexValueMap, setEdgeColor, setVertexColor, setVertexValueaddEdge, addEdge, addVertex, addVertex, clone, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeSupplier, setEdgeWeight, setVertexSupplier, vertexSetassertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetspublic DirectedWeightedGraph(Tree tree)
tree - the Tree to be convertedIllegalArgumentException - if Tree contains multiple rootspublic DirectedWeightedGraph(Tree tree, boolean assignDistancesToWeight)
tree - the Tree to be convertedassignDistancesToWeight - whether to assign inter-node distances between adjacent points as edge weightsIllegalArgumentException - if Tree contains multiple rootspublic DirectedWeightedGraph()
assignEdgeWeightsEuclidean(),
Graph.setEdgeWeight(Object, Object, double),
AbstractBaseGraph.setEdgeWeight(Object, double)public DirectedWeightedGraph(Collection<SWCPoint> nodes, boolean assignDistancesToWeight)
nodes - the collections of SWC nodesassignDistancesToWeight - if true, inter-node Euclidean distances are
used as edge weightspublic DirectedWeightedGraph getSimplifiedGraph()
IllegalStateException - if the base graph does not have exactly one rootpublic SWCPoint addVertex(double x, double y, double z)
public void assignEdgeWeightsEuclidean()
public void scale(double xScale,
double yScale,
double zScale,
boolean updateEdgeWeightsEuclidean)
xScale - the scaling factor for x coordinatesyScale - the scaling factor for y coordinateszScale - the scaling factor for z coordinatesupdateEdgeWeightsEuclidean - if true, update all edge weights with
inter-node Euclidean distancespublic double sumEdgeWeights()
public org.jgrapht.traverse.DepthFirstIterator<SWCPoint,SWCWeightedEdge> getDepthFirstIterator()
DepthFirstIterator, using the graph root as start vertex.IllegalStateException - if the graph does not have exactly one rootpublic org.jgrapht.traverse.DepthFirstIterator<SWCPoint,SWCWeightedEdge> getDepthFirstIterator(SWCPoint startVertex)
DepthFirstIterator, using the specified start vertex.startVertex - the start vertexpublic org.jgrapht.traverse.BreadthFirstIterator<SWCPoint,SWCWeightedEdge> getBreadthFirstIterator()
BreadthFirstIterator, using the graph root as start vertex.IllegalStateException - if the graph does not have exactly one rootpublic org.jgrapht.traverse.BreadthFirstIterator<SWCPoint,SWCWeightedEdge> getBreadthFirstIterator(SWCPoint startVertex)
BreadthFirstIterator, using the specified start vertex.startVertex - the start vertexpublic Path getLongestPath(boolean useDirected)
Path.useDirected - whether to treat the graph as directed.
If true, the longest shortest-path will always include the root and a terminal node.IllegalStateException - if the graph does not have exactly one rootpublic Deque<SWCPoint> getLongestPathVertices(boolean useDirected)
Deque. This eliminates the computational overhead of converting the vertex sequence
to a Path object, if a Path is not desired.useDirected - whether to treat the graph as directed.
If true, the longest shortest-path will always include the root and a terminal node.IllegalStateException - if the graph does not have exactly one rootpublic Path getShortestPath(SWCPoint v1, SWCPoint v2)
Path object.
Since underlying edge direction is ignored, a shortest path will always exist between
any two vertices that share a connected component.v1 - the source vertexv2 - the target vertexIllegalArgumentException - if the graph does not contain both v1 and v2public Deque<SWCPoint> getShortestPathVertices(SWCPoint v1, SWCPoint v2)
Deque of SWCPoint objects.
This eliminates the computational overhead of creating a Path object from the vertex sequence,
if a Path is not desired.
Since underlying edge direction is ignored, a shortest path will always exist between
any two vertices that share a connected component.v1 - the source vertexv2 - the target vertexIllegalArgumentException - if the graph does not contain both v1 and v2public void updateVertexProperties()
IllegalStateException - if the graph does not contain exactly one rootpublic List<SWCPoint> getBPs()
public List<SWCPoint> getTips()
public NodeStatistics<SWCPoint> getNodeStatistics()
public NodeStatistics<SWCPoint> getNodeStatistics(String type)
type - the vertex type (e.g., "tips"/"end-points", "junctions"/"branch points", "all")public SWCPoint getRoot()
IllegalStateException - if the graph does not contain exactly one rootpublic Tree getTree()
IllegalStateException - if the graph does not have exactly one rootpublic Tree getTree(boolean createNewTree)
createNewTree - If true, reassembles a tree from this graph's data.
If false, returns the cached tree if it exists or null if it does not existpublic Tree getTreeWithSamePathStructure()
Path hierarchy as the source Tree.public List<DirectedWeightedGraph> getComponents()
DirectedWeightedGraphs.public List<Tree> getTrees()
Treespublic DirectedWeightedSubgraph getSubgraph(Set<SWCPoint> nodeSubset)
nodeSubset - a subset of this graph's vertex setpublic Set<SWCPoint> vertexSet(char lr)
lr - the hemisphere (i.e., BrainAnnotation.LEFT_HEMISPHERE, BrainAnnotation.RIGHT_HEMISPHERE
,BrainAnnotation.ANY_HEMISPHEREpublic void setRoot(SWCPoint newRoot)
newRoot - the new root of the tree, which must be an existing vertex of the graphIllegalArgumentException - if the graph does not contain newRootpublic Window show()
IllegalStateException - if the graph does not have exactly one rootCopyright © 2018–2021 Morphonets. All rights reserved.