Skip to content

Trait Rework: AdjacencyMatrix #558

@indietyp

Description

@indietyp

Instead of implementing the adjacency matrix on the graph directly (violating separation of concerns) this instead splits the GetAdjacencyMatrix into two traits: GraphAdjacencyMatrix (which is implemented for graphs) and AdjacencyMatrix, which is the actual AdjacencyMatrix

// potential default implementation for AdjacencyMatrix, based on a `FixedBitSet`
// pub struct DefaultAdjacencyMatrix {}

pub trait AdjacencyMatrix {
	type Index;

	fn is_adjacent(a: Self::Index, b: Self::Index) -> bool;
}

pub trait GraphAdjacencyMatrix: IndexableGraph {
	type AdjacencyMatrix<'a>: AdjacencyMatrix<Index = Self::NodeIndex> where Self: 'a;

	fn adjacency_matrix(&self) -> Self::AdjacencyMatrix<'_>;
}

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