Skip to content

Conversation

dizzyi
Copy link
Contributor

@dizzyi dizzyi commented Aug 4, 2025

Development Workflow

  • make format
  • make test
  • make lint

Minimal API change

all the test files are untouched, and all the test passed.

Types Changes

Remove and modified custom type and opt-in for petgraph's provided types. this can

  • allow easier usage and intergration to petgraph.
  • cleaner interface, generic param.

GraphConstructor -> petgraph::EdgeType

GraphConstructor provide the two function interface:

fn is_directed() -> bool: already provided by EdgeType trait, which both petgraph::Directed and petgraph::Undirected already implemented, and

fn new_graph() -> PetGraph<A, W, Self>: which is used total 2 times in the codebase, which can be easily inlined.

pub use petgraph::EdgeType;

Directed and Undirected

Directed and Undirected has same name type provided by petgraph.

graphina's type provide:

  • function is_directed()->bool, which petgraph's already implemented
  • trait impl Default::default(), which is never used in the code base
/// Marker type for directed graphs.
pub use petgraph::{Directed, Undirected};

NodeId and EdgeId

struct NodeId(NodeIndex) and struct EdgeId(EdgeIndex), provide no extra functionalities, it'll be easier to use as alias to the petgraph's NodeIndex and EdgeIndex

/// Alias for `NodeIndex`
pub type NodeId = NodeIndex;
/// Alias for `EdgeIndex`
pub type EdgeId = EdgeIndex;

API change example

src/core/types.rs:202: BaseGraph::add_edge

from

    EdgeId::new(self.inner.add_edge(source.0, target.0, weight))

to

    self.inner.add_edge(source, target, weight)

@dizzyi dizzyi marked this pull request as ready for review August 4, 2025 05:08
@habedi
Copy link
Owner

habedi commented Aug 4, 2025

Thanks for the changes.

Can you have a look at #13 and write your counterarguments against the two reasons that I mentioned there?

@habedi habedi self-assigned this Aug 4, 2025
@habedi habedi added development Development-related work Idea Ideas labels Aug 4, 2025
@dizzyi dizzyi closed this Aug 6, 2025
@dizzyi dizzyi deleted the types branch August 7, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Development-related work Idea Ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants