Package noduledistances.imagej
Class RootGraph
java.lang.Object
noduledistances.imagej.RootGraph
The purpose of the class RootGraph is to hold all information related to the graph derived from
the initial image, including the data and methods to translate between the abstract graph and
the point and edges on the skeleton of the image.
The class also holds all computational methods relating to the abstract graph.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRootGraph(ArrayList<ArrayList<int[]>> skeleton, GraphOverlay graphOverlay) constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an edge to the graph.voidaddNodules(ArrayList<int[]> nodLocations) adds the set of nodules as Node objects to the graph by connecting each nodule node to the nearest node currently within the graph with an edge.ArrayList<int[]>ballSubgraph(int numNodes, Point2D pt) Find the numNodes closest Nodes to the given pt, and finds all edges that contain any of those nodes.ArrayList<ij.gui.ShapeRoi>ballSubgraphLines(int numNodes, Point2D pt) Find the numNods closest nodes to the given point, then creates an arrayList of lines that are all edges containing any of the closest nodes.
i.e. it records all edges containing the numNodes closest nodes, returning them as Roi objects.protected intcomputeLengthOfPath(List<edu.asu.emit.algorithm.graph.abstraction.BaseVertex> path) Computes the length of the given path. i.e. the sum of the lengths of the lines between each arc in the path.voidcomputeShortestDistances(int numIterations) Computes and stores the all-pairs distance calculations between all Nodules numIteration times.booleancontainsEdge(int a, int b) Checks whether the graph contains the edge [a,b].protected com.programmerare.edu.asu.emit.algorithm.graph.GraphWithConstructorcreates a graph structure using Yan Qi's graph package to utilize their implementation of k shortest paths.getInstances(Point node) Finds searches for all in-arcs of the given node.Node[]voidmergeNonemptyComponents(ArrayList<int[]> components) Used to merge disconnected parts of the graph to create one connected graph.ArrayList<int[]>Returns the subgraph that is all edges containing a nodule node as at least one of the nodes.voidremoveEdge(Node[] nodeEdge) method for removing the given edge.protected ArrayList<int[]>shortestPathsToList(List<edu.asu.emit.algorithm.graph.Path> shortest_paths_list) converts the list of computed shortest paths to an ArrayList of Arrays of ints.
-
Field Details
-
skeleton
-
numNodules
public int numNodules -
nodes
Node is an extension of java.awt.point that includes an identifier for the node, i.e. Node.type == 0 -> skeleton node type == 1 -> red nodule type == 2 -> green nodule type == 3 -> mixed nodule
-
-
Constructor Details
-
RootGraph
constructor. Constructs the graph object from the skeleton. LingDong's algorithm wasn't designed to convert the skeleton into a graph, so sometimes the graph becomes disconnected when the provided object it's skeletonizing is connected. We attempt to amend this by saying that any two nodes from the skeleton are the same if they are within 8 pixels (refer to Node.equals). We also add edges at the end if two nodes are within 9 pixels.- Parameters:
skeleton- : skeleton object from LingDong's skeletonization algorithm.graphOverlay- : graphOverlay object which holds the root system image and the graph overlaying it.
-
-
Method Details
-
addEdge
Adds an edge to the graph.- Parameters:
edge- : edge to add to the graph.
-
removeEdge
method for removing the given edge.- Parameters:
nodeEdge- : edge to remove. nodeEdge should be an array of size 2, one for each endpoint of the edge
-
mergeNonemptyComponents
Used to merge disconnected parts of the graph to create one connected graph.- Parameters:
components- : parts of the graph that are disconnected.
-
getInstances
Finds searches for all in-arcs of the given node.- Parameters:
node- : node to find the in-arc for- Returns:
- : all points who has arcs entering the given node.
-
addNodules
adds the set of nodules as Node objects to the graph by connecting each nodule node to the nearest node currently within the graph with an edge.- Parameters:
nodLocations- a list of x,y coordinates of the contour centroids of the polygon outlines of the nodules.
-
containsEdge
public boolean containsEdge(int a, int b) Checks whether the graph contains the edge [a,b].- Parameters:
a- : source node of arc in question.b- : sink node of arc in question.- Returns:
- : true if such an arc exists. False otherwise.
-
computeShortestDistances
public void computeShortestDistances(int numIterations) Computes and stores the all-pairs distance calculations between all Nodules numIteration times. In each iteration, we remove a different edge- Parameters:
numIterations- : the number of times we compute the distance calculations.
-
shortestPathsToList
protected ArrayList<int[]> shortestPathsToList(List<edu.asu.emit.algorithm.graph.Path> shortest_paths_list) converts the list of computed shortest paths to an ArrayList of Arrays of ints.- Parameters:
shortest_paths_list- : object to convert.- Returns:
- : converted object.
-
computeLengthOfPath
Computes the length of the given path. i.e. the sum of the lengths of the lines between each arc in the path.- Parameters:
path- : path to compute the length of.- Returns:
- : length of the given path.
-
convertToYanGraph
protected com.programmerare.edu.asu.emit.algorithm.graph.GraphWithConstructor convertToYanGraph()creates a graph structure using Yan Qi's graph package to utilize their implementation of k shortest paths.- Returns:
- YanQi's graph object.
-
getNodules
- Returns:
- : the set of nodes of the graph that are nodules.
-
ballSubgraphLines
Find the numNods closest nodes to the given point, then creates an arrayList of lines that are all edges containing any of the closest nodes.
i.e. it records all edges containing the numNodes closest nodes, returning them as Roi objects.- Parameters:
numNodes- : number of nodes to find the edges ofpt- : point to search around.- Returns:
- : an arraylist of ShapeRoi lines which are the edges containing the edges of the numNodes closest nodes.
-
ballSubgraph
Find the numNodes closest Nodes to the given pt, and finds all edges that contain any of those nodes.- Parameters:
numNodes- : number of nodes to find.pt- : point to search around.- Returns:
- : subgraph containing the numNodes closest nodes and all edges related to,them.
-
noduleFSRep
Returns the subgraph that is all edges containing a nodule node as at least one of the nodes.- Returns:
- The forward star representation as an ArrayList of Arrays of ints.
-