Skip to content

Trait Rework: Subgraph crate #553

@indietyp

Description

@indietyp

The tracking issue for the subgraph proposal, replacing visit::FilterEdge, EdgeFiltered, visit::FilterNode, NodeFiltered with a new crate petgraph-subgraph.

Instead of having multiple adapters that filter by a specific edge, that must be implemented, we choose to expose a single new graph type: Subgraph, which acts like any other graph but allows to exclude edges and noes from the graph.

pub trait Filter<T> {
	fn call(&self, value: T) -> bool;
}

pub enum Include {
	All,
	Only(HashSet<T>)  // <- or any other set
}

pub struct Subgraph<T> where T: GraphBase {
	graph: T,

	nodes: Include<T::NodeId>,
	edges: Include<T::EdgeId>
}

impl Subgraph<T> {
	// Include all. The name is not great
	fn new(graph: T) -> Self;

	// names TBD
	fn only_include_edges<U>(&mut self, edges: U) where U: Filter<T::EdgeId>;
	fn only_include_nodes<U>(&mut self, nodes: U) where U: Filter<T::NodeId>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crateArea: Petgraph crate functionalityC-tracking-issueAn issue/PR that collects information about a broad development initiativeF-trait-reworkFeature: Trait Rework

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions