Skip to content
Draft
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0cf2719
started to update some import issues
cainja Jun 3, 2025
9915650
fixing compiler errors
cainja Jun 5, 2025
fb498be
fixed compiler errors for angiogenesis
cainja Jun 8, 2025
1748fca
spotless
cainja Jun 8, 2025
363d67f
updated core graph utilities
cainja Jun 10, 2025
74c0da2
doc string
cainja Jun 10, 2025
86ba444
bisection precision tests
cainja Jun 10, 2025
3e15f8b
slight refactor
cainja Jun 10, 2025
e146543
renamed function
cainja Jun 10, 2025
e9d09f9
capitalization error
cainja Jun 10, 2025
17f8d9c
java docs
cainja Jun 10, 2025
a9fd46f
placeholder docstrings
cainja Jun 10, 2025
9a2bc91
spotless
cainja Jun 10, 2025
946889c
added tests for register and scheduler
cainja Jun 13, 2025
253aad3
added test for getPath
cainja Jun 13, 2025
0ba65bf
cleaning up growth component
cainja Jun 13, 2025
2c832e6
removing redundant variables
cainja Jun 14, 2025
5dda2c9
updated some javadocs
cainja Jun 14, 2025
bd7ee7f
linter updates
cainja Jun 15, 2025
fdd8d07
updated to work with multiple veins
cainja Jun 16, 2025
943281d
updated boolean argument
cainja Jun 16, 2025
5197158
updated doc strings
cainja Jun 16, 2025
eb06923
updated for consistency
cainja Jun 17, 2025
4d2fe52
added input argument into string
cainja Jun 17, 2025
a7572c1
removed some useless code
cainja Jun 18, 2025
98ad1bf
added doc string
cainja Jun 18, 2025
bf1ca4c
cleaned up some error passing
cainja Jun 23, 2025
a19778e
i have a lot of logging stuff right now
cainja Jun 27, 2025
28dfc5c
it's a different bug now
cainja Jun 30, 2025
cab2f02
updated some matrix maths, adding some log statements trying to figur…
cainja Jul 3, 2025
9f169a0
spotless
cainja Jul 3, 2025
6037755
updated default threshold
cainja Jul 3, 2025
6006b41
added transport
cainja Jul 3, 2025
3cce139
added fraction
cainja Jul 3, 2025
e48151f
fixed directional check based on level
cainja Jul 4, 2025
2086199
edges are still being removed before establishing
cainja Jul 7, 2025
8bb6ef6
still not establishing edges
cainja Jul 7, 2025
2399cb4
still having pointer issues
cainja Jul 8, 2025
79bc465
temp edge fix
kristaphommatha Jul 11, 2025
5cf3045
adding more specific debug log info
kristaphommatha Jul 11, 2025
cfad7eb
debug logging
kristaphommatha Jul 11, 2025
5e74cb3
more debug logs
kristaphommatha Jul 12, 2025
db39c38
fix connecting two angio nodes and null sproutDir
kristaphommatha Jul 15, 2025
b1d605e
simulation growth is behaving abnormally
cainja Jul 17, 2025
317484a
remove node delay logic
cainja Jul 20, 2025
d931ac1
changed node verification logic
cainja Jul 25, 2025
df34e85
Fixed mergeGraph() node map problem, added more debug logs
kristaphommatha Jul 29, 2025
f94e0da
style fixes
kristaphommatha Jul 29, 2025
7cec022
fixing undefined edge direction, debug logger for angiogenicNodeMap t…
kristaphommatha Jul 29, 2025
45ad5b3
fixing keyNodesToRemove logic
kristaphommatha Jul 29, 2025
7656e5c
fixed issue where two sproutNodes intersected on the same edgeList
kristaphommatha Aug 1, 2025
36d6e6a
removing debug logs, add updateRadiusToRoot back
kristaphommatha Aug 1, 2025
7ab6c1a
resolved conflict
cainja Aug 3, 2025
b3da84a
added back in node delay logic, removed superfluous logging statements
cainja Aug 3, 2025
9632e82
removed unnecessary node list
cainja Aug 3, 2025
06db7cb
changing path.isEmpty() logic
kristaphommatha Aug 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 99 additions & 2 deletions src/arcade/core/util/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public enum Strategy {
/** Collection of all {@code Edge} objects in a graph. */
private final Bag allEdges;

/** Map of {@code Node} objects, for lookup. */
private final Map<String, Node> nodes;

/** Map of {@code Node} OUT to bag of {@code Edge} objects. */
private final Map<Node, Bag> nodeToOutBag;

Expand All @@ -42,6 +45,7 @@ public Graph() {
allEdges = new Bag();
nodeToOutBag = new HashMap<>();
nodeToInBag = new HashMap<>();
nodes = new HashMap<>();
}

/**
Expand All @@ -53,13 +57,32 @@ public void update(Graph graph) {
allEdges.addAll(graph.allEdges);
nodeToOutBag.putAll(graph.nodeToOutBag);
nodeToInBag.putAll(graph.nodeToInBag);
updateNodes();
}

/** Updates nodes from graph. */
private void updateNodes() {
nodes.clear();
for (Object obj : allEdges) {
Edge edge = (Edge) obj;
Node from = edge.getFrom();
Node to = edge.getTo();

if (!nodes.containsKey(from.toString())) {
nodes.put(from.toString(), from);
}
if (!nodes.containsKey(to.toString())) {
nodes.put(to.toString(), to);
}
}
}

/** Clear edges and nodes from graph. */
public void clear() {
allEdges.clear();
nodeToOutBag.clear();
nodeToInBag.clear();
nodes.clear();
}

/**
Expand Down Expand Up @@ -91,6 +114,28 @@ public boolean contains(Edge edge) {
return checkEdge(edge);
}

/**
* Retrieve the node object for the given coordinates. Returns null if no node exists.
*
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coordinate
* @return the node object
*/
public Node lookup(int x, int y, int z) {
return nodes.get("(" + x + "," + y + "," + z + ")");
}

/**
* Retrieve the node object for the given coordinates. Returns null if no node exists.
*
* @param node to lookup an original node
* @return the node object
*/
public Node lookup(Node node) {
return nodes.get(node.toString());
}

/**
* Gets all edges in the graph.
*
Expand Down Expand Up @@ -255,6 +300,8 @@ public void mergeNodes() {
e.setTo(join);
}
}

nodes.put(join.toString(), join);
}
}

Expand All @@ -278,6 +325,27 @@ public void addEdge(Edge edge) {
setOutMap(edge.getFrom(), edge);
setInMap(edge.getTo(), edge);
setLinks(edge);
addNodes(edge);
}

/**
* Helper function to adds the nodes from an edge to a graph.
*
* @param edge the edge to add
*/
private void addNodes(Edge edge) {
Node from = edge.getFrom();
Node to = edge.getTo();
if (!nodes.containsKey(from.toString())) {
nodes.put(from.toString(), from);
} else {
from = nodes.get(from.toString());
}
if (!nodes.containsKey(to.toString())) {
nodes.put(to.toString(), to);
} else {
to = nodes.get(to.toString());
}
}

/**
Expand Down Expand Up @@ -353,6 +421,19 @@ public void removeEdge(Edge edge) {
unsetOutMap(edge.getFrom(), edge);
unsetInMap(edge.getTo(), edge);
unsetLinks(edge);
removeNodeIfDetached(edge.getFrom());
removeNodeIfDetached(edge.getTo());
}

/**
* Remove a node if it is detached from the graph.
*
* @param node the node to check
*/
private void removeNodeIfDetached(Node node) {
if (!nodeToInBag.containsKey(node) && !nodeToOutBag.containsKey(node)) {
nodes.remove(node.toString());
}
}

/**
Expand Down Expand Up @@ -730,7 +811,8 @@ public static class Edge {
private final ArrayList<Edge> edgesOut;

/**
* Creates an {@code Edge} between two {@link Node} objects.
* Creates an {@code Edge} between two {@link Node} objects. Default behavior is to
* duplicate nodes.
*
* @param from the node the edge is from
* @param to the node the edge is to
Expand All @@ -742,6 +824,21 @@ public Edge(Node from, Node to) {
edgesOut = new ArrayList<>();
}

/**
* Creates an {@code Edge} object for graph sites. Used in cases where a new node object is
* not needed.
*
* @param from the node the edge is from
* @param to the node the edge is to
* @param duplicate {@code true} if nodes should be duplicated, {@code false} otherwise
*/
public Edge(Node from, Node to, boolean duplicate) {
this.from = duplicate ? from.duplicate() : from;
this.to = duplicate ? to.duplicate() : to;
edgesIn = new ArrayList<>();
edgesOut = new ArrayList<>();
}

/**
* Gets the node the edge points to based on the calculation strategy (e.g. upstream or
* downstream).
Expand Down Expand Up @@ -822,7 +919,7 @@ public ArrayList<Edge> getEdgesOut() {
*
* @return the reversed edge
*/
Edge reverse() {
public Edge reverse() {
Node tempTo = to;
Node tempFrom = from;
to = tempFrom;
Expand Down
129 changes: 129 additions & 0 deletions src/arcade/core/util/MatrixArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package arcade.core.util;

import java.util.ArrayList;
import java.util.Collections;
import arcade.core.util.Matrix.Value;

/**
* Container class for array-based sparse matrix representation.
*
* <p>Class provides a subset of matrix operations needed for solving a system of linear equations
* using the successive over-relaxation method in {@link arcade.core.util.Solver}.
*/
public class MatrixArray {
public MatrixArray(double[][] a) {

Check failure on line 14 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L14 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:14:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
nRows = a.length;
if (nRows == 0) {
throw new IllegalArgumentException("MatrixArray ctor: input is empty");
}
nColumns = a[0].length;

if (nColumns == 0) {
throw new IllegalArgumentException("Matrix array ctor: empty columns");
}

ArrayList<Value> alValues = new ArrayList<>();
int nNonZero = 0;
for (int row = 0; row < nRows; row++) {
if (a[row].length != nColumns) {
throw new IllegalArgumentException(
"Matrix array ctor: not all columns are the same length");
}

for (int column = 0; column < nColumns; column++) {
if (a[row][column] != 0.) {
alValues.add(new Value(row, column, a[row][column]));
nNonZero++;
}
}
}

//
// No need to sort, since we built them in order.
//

values = new Value[nNonZero];
int i = 0;
for (Value v : alValues) {
values[i] = v;
i++;
}
} // ctor

public MatrixArray(ArrayList<Value> alValues, int i_nRows, int i_Columns) {

Check failure on line 53 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L53 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:53:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)

Check failure on line 53 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L53 <com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck>

Name 'i_nRows' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:53:55: error: Name 'i_nRows' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck)

Check failure on line 53 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L53 <com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck>

Name 'i_Columns' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:53:68: error: Name 'i_Columns' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck)
nRows = i_nRows;
nColumns = i_Columns;
values = new Value[alValues.size()];

Collections.sort(
alValues,
(v1, v2) -> (v1.i == v2.i ? Integer.compare(v1.j, v2.j) : (v1.i > v2.i ? 1 : -1)));

int i = 0;
for (Value v : alValues) {
values[i] = v;
i++;
}
}

/**
* Solves the equation {@code Lx = b} using forward substitution for an array-based sparse
* matrix.
*
* @param b the right-hand side vector
* @return the left-hand side vector
*/
public double[] forwardSubstitution(double[] b) {

int n = b.length;
double[] subbed = new double[n];
double[] diag = new double[n];

// Group lower diagonal by row.
ArrayList<ArrayList<Value>> rowsL = new ArrayList<ArrayList<Value>>();
for (int r = 0; r < n; r++) {
rowsL.add(new ArrayList<>());
}
for (Value v : values) {
rowsL.get(v.i).add(v);
}

// Get values along diagonal.
for (Value v : values) {
if (v.i == v.j) {
diag[v.i] = v.v;
}
}

// Iterate only through non-zero entries in the lower diagonal matrix.
for (int i = 0; i < n; i++) {
ArrayList<Value> rowL = rowsL.get(i);
double val = 0;
for (Value v : rowL) {
val += subbed[v.j] * v.v;
}
val = b[i] - val;
subbed[i] = val / diag[i];
}

return subbed;
}

public double[] multiply(double[] b) {

Check failure on line 112 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L112 <com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck>

Class 'MatrixArray' looks like designed for extension (can be subclassed), but the method 'multiply' does not have javadoc that explains how to do that safely. If class is not designed for extension consider making the class 'MatrixArray' final or making the method 'multiply' static/final/abstract/empty, or adding allowed annotation for the method.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:112:5: error: Class 'MatrixArray' looks like designed for extension (can be subclassed), but the method 'multiply' does not have javadoc that explains how to do that safely. If class is not designed for extension consider making the class 'MatrixArray' final or making the method 'multiply' static/final/abstract/empty, or adding allowed annotation for the method. (com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck)

Check failure on line 112 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L112 <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:112:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
if (b.length != nRows) {
throw new IllegalArgumentException("MatrixArray.multiply (by a vector): conformation");
}
double[] multiplied = new double[nRows];

// Iterate through all entries and multiply.
for (Value a : values) {
multiplied[a.i] += a.v * b[a.j];
}

return multiplied;
}

int nRows;

Check failure on line 126 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L126 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:126:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck)
int nColumns;

Check failure on line 127 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L127 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:127:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck)

Check failure on line 127 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L127 <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck>

'VARIABLE_DEF' should be separated from previous line.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:127:5: error: 'VARIABLE_DEF' should be separated from previous line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)
Value[] values;

Check failure on line 128 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L128 <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck>

Missing a Javadoc comment.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:128:5: error: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck)

Check failure on line 128 in src/arcade/core/util/MatrixArray.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/core/util/MatrixArray.java#L128 <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck>

'VARIABLE_DEF' should be separated from previous line.
Raw output
/github/workspace/./src/arcade/core/util/MatrixArray.java:128:5: error: 'VARIABLE_DEF' should be separated from previous line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)
}
Loading
Loading