Skip to content

GraphMap: add Entry API#289

Open
jmcomets wants to merge 1 commit intopetgraph:masterfrom
jmcomets:graphmap-edge-entry
Open

GraphMap: add Entry API#289
jmcomets wants to merge 1 commit intopetgraph:masterfrom
jmcomets:graphmap-edge-entry

Conversation

@jmcomets
Copy link
Collaborator

This adds an edge_entry() method to GraphMap's public interface along with
a thin wrapper over an IndexMap entry.

Differences with the wrapped entry:

  • source(): returns the source edge, replacing key()
  • target(): returns the target edge, replacing key()

Note that this enables merging parallel edges, which currently requires quite a
ceremony.

For example, when counting occurrences:

// before
if let Some(old) = gr.add_edge("x", "y", 1) {
    gr.add_edge("x", "y", old + 1);
}

// after
*gr.edge_entry("x", "y").or_insert(0) += 1;

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 this pull request may close these issues.

1 participant