Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FeatureReq]: Host function iteration over directed graph edges #1237

Closed
DavidFletcherShef opened this issue Oct 15, 2024 · 0 comments · Fixed by #1273
Closed

[FeatureReq]: Host function iteration over directed graph edges #1237

DavidFletcherShef opened this issue Oct 15, 2024 · 0 comments · Fixed by #1273

Comments

@DavidFletcherShef
Copy link

Is your feature request related to a problem?

On the host it appears to be impossible to easily iterate through all the edges on a directed graph. It would be really useful if this facility was available.

Edges can be addressed using the format:

HostEnvironmentDirectedGraph::EdgeMap::Edge edge = edges[{i,j}];

But to do that you need to already know the source and target vertices. Iterating without this prior knowledge would be very useful.

Describe the solution you'd like

Agent functions offer graph.getEdgeSource(index) in which index is a single number that easily allows you to move through all edges, but from the agent function you can't then update the directed graph environment variable. Having similar iteration capability to work through all edges on the host would be really useful.

Describe alternatives you've considered

My current solution is to perform the calculation in an agent function when needed, but this means repeated output is being generated that could otherwise have been calculated once for each edge and stored.

Additional context

Iterating over the edges without knowing source and target is useful (for example) when a directed graph has been read in from a JSON file. Taking the graph to represent the spatial position of a series of locations it's useful for an initialisation function to pre-calculate and store within the graph the length of each edge. That's better than storing in the JSON and needing to keep the length in sync with any change of the vertices.

Robadob added a commit that referenced this issue Jan 19, 2025
This necessitated updating Edge/Vertex classes to internally track via index rather than ID.
This removed redundant index lookups from every accessor, so will have negligbly improved performance.

EdgeMap and VertexMap are now franken datastructures, which have attributes of both maps and arrays.
This is great for usability, but has the potential to confuse users that don't read documentation.

Tests extended in C & Python to cover this.

Closes #1237
mondus pushed a commit that referenced this issue Jan 21, 2025
This necessitated updating Edge/Vertex classes to internally track via index rather than ID.
This removed redundant index lookups from every accessor, so will have negligbly improved performance.

EdgeMap and VertexMap are now franken datastructures, which have attributes of both maps and arrays.
This is great for usability, but has the potential to confuse users that don't read documentation.

Tests extended in C & Python to cover this.

Closes #1237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant