Skip to content

Commit

Permalink
Add access to Links to AbstractExampleGraph
Browse files Browse the repository at this point in the history
* Add method getBranchLink()
* Let method addEdge() return the created Link
  • Loading branch information
stefanhahmann authored and tinevez committed Feb 26, 2024
1 parent d53bcd8 commit f7e69ec
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

import javax.annotation.Nonnull;

import org.mastodon.mamut.model.Link;
import org.mastodon.mamut.model.Model;
import org.mastodon.mamut.model.ModelGraph;
import org.mastodon.mamut.model.Spot;
import org.mastodon.mamut.model.branch.BranchLink;
import org.mastodon.mamut.model.branch.BranchSpot;
import org.mastodon.mamut.model.branch.ModelBranchGraph;

Expand Down Expand Up @@ -70,6 +72,12 @@ public BranchSpot getBranchSpot(@Nonnull Spot spot)
return modelBranchGraph.getBranchVertex( spot, modelBranchGraph.vertexRef() );
}

public BranchLink getBranchLink( @Nonnull Link link )
{
rebuiltGraphIfRequired();
return modelBranchGraph.getBranchEdge( link, modelBranchGraph.edgeRef() );
}

private void rebuiltGraphIfRequired()
{
if ( ! branchGraphRequiresRebuild )
Expand All @@ -87,9 +95,10 @@ protected Spot addNode( @Nonnull String label, int timepoint, double[] xyz )
return spot;
}

protected void addEdge( @Nonnull Spot source, @Nonnull Spot target )
protected Link addEdge( @Nonnull Spot source, @Nonnull Spot target )
{
modelGraph.addEdge( source, target );
Link link = modelGraph.addEdge( source, target );
branchGraphRequiresRebuild = true;
return link;
}
}

0 comments on commit f7e69ec

Please sign in to comment.