Crates.io | line-graph |
lib.rs | line-graph |
version | 0.1.0 |
source | src |
created_at | 2022-02-10 17:15:35.716104 |
updated_at | 2022-02-10 17:15:35.716104 |
description | Construct the line graph of an undirected graph |
homepage | |
repository | https://github.com/a-maier/line-graph |
max_upload_size | |
id | 530366 |
size | 5,486 |
Construct the line graph of an undirected graph
This crate provides a single function that takes an undirected petgraph graph and constructs the corresponding line graph. Node weights are turned into edge weights and vice versa.
The triangle graph is the same as its line graph.
use line_graph::line_graph;
use petgraph::{
algo::is_isomorphic,
graph::UnGraph
};
let g = UnGraph::<(), ()>::from_edges([(0, 1), (1, 2), (2, 0)]);
let g_line = line_graph(&g);
assert!(is_isomorphic(&g, &g_line));
If edges are connected by two vertices, the corresponding vertices in the line graph will also be connected by two edges.
License: MIT OR Apache-2.0