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

Add option to use a preexisting graph in graph_4_adjacency_2_khalimsky #244

Closed
PerretB opened this issue Dec 7, 2021 · 0 comments · Fixed by #262
Closed

Add option to use a preexisting graph in graph_4_adjacency_2_khalimsky #244

PerretB opened this issue Dec 7, 2021 · 0 comments · Fixed by #262
Labels
enhancement Evolution of existing feature

Comments

@PerretB
Copy link
Member

PerretB commented Dec 7, 2021

The function graph_4_adjacency_2_khalimsky always allocate a new graph which might be inefficient for certain use case where the graph could be reused

def khalimsky_2_graph_4_adjacency(khalimsky, extra_border=False):
"""
Create a 4 adjacency edge-weighted graph from a contour image in the Khalimsky grid.
:param khalimsky: a 2d array
:param extra_border: if False the shape of the Khalimsky image is 2 * shape - 1 and 2 * shape + 1 otherwise, where shape is the shape of the resulting grid graph
:return: a graph (Concept :class:`~higra.CptGridGraph`) and its edge weights
"""
graph, embedding, edge_weights = hg.cpp._khalimsky_2_graph_4_adjacency(khalimsky, extra_border)
hg.CptGridGraph.link(graph, hg.normalize_shape(embedding.shape()))
hg.set_attribute(graph, "no_border_vertex_out_degree", 4)
return graph, edge_weights

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Evolution of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant