Skip to content

Trait Rework: New traits #559

@indietyp

Description

@indietyp

This proposes several new traits that are useful in manipulating existing graphs.

pub trait GraphMap {
	type Output;

	fn map<'a, F, G, N, E>(&self, nodes: F, edges: G) -> Self::Output<N, E>;
}

// mutable access could be modelled over `for node in g.nodes_mut() { node = ... }`

pub trait GraphFilterMap {
	type Output;

	fn filter_map<'a, F, G, N, E>(&self, nodes: F, edges: G) -> Self::Output<N, E>;
}

pub trait GraphRetain {
	fn retain_nodes<F>(&mut self, visit: F);
	fn retain_edges<F>(&mut self, visit: F);
}

These are modeled after Graph (and StableGraph) as they are currently the most fully featured.

We might want to think about the following:

  • edge_connecting()
  • contains_edge()
  • find_edge()
  • find_edge_undirected()
  • externals()
  • node_weights()
  • node_weights_mut()
  • neighbors_undirected()
  • reverse()
  • Entry API

On Graph, there are the following duplicates:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions