Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolated vertex with largest node id #123

Closed
Steditor opened this issue Nov 27, 2023 · 1 comment
Closed

Isolated vertex with largest node id #123

Steditor opened this issue Nov 27, 2023 · 1 comment

Comments

@Steditor
Copy link

Hi there,
is there a way of building a graph where the highest node index in the edge list does not correspond to the number of vertices; thus: there are isolated vertices with higher node indices? Maybe I missed it but I did not find such a way in the documentation.

@knutwalker
Copy link
Collaborator

Hi,

with 0.3.1 (#117), the node count is derived from the node_values, if they are present. If you don't have any, you can use (), which won't end up allocating anything:

let g0: UndirectedCsrGraph<u32> = GraphBuilder::new()
    .edges(vec![(0, 1), (1, 2)])
    .node_values(vec![(); 4])  // <<== add a Vec<()> of size `node_count`
    .build();

assert_eq!(g0.node_count(), 4);
assert_eq!(g0.degree(3), 0);

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

No branches or pull requests

2 participants