From 20ab49c542e24fe2926d70d632ff3a027573bf22 Mon Sep 17 00:00:00 2001 From: Mostafizur Date: Thu, 8 May 2025 16:51:59 +0530 Subject: [PATCH 1/8] added documentation for using read_edge_list function --- src/graph.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index 8b361767c5..8e3e45fd5f 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1167,7 +1167,7 @@ impl PyGraph { #[pyo3(text_signature = "(self, node, /)")] pub fn adj(&mut self, node: usize) -> DictMap { let index = NodeIndex::new(node); - self.graph + self.graphdel .edges_directed(index, petgraph::Direction::Outgoing) .map(|edge| (edge.target().index(), edge.weight())) .collect() @@ -1368,8 +1368,15 @@ impl PyGraph { /// fd.write('2 3\n') /// fd.flush() /// graph = rx.PyGraph.read_edge_list(path=path) - /// mpl_draw(graph) - /// + /// + /// For example for csv based data, you may use the below code + /// + /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") + /// + /// Data with labels for nodes + /// + /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",",labels=True) + /// #[staticmethod] #[pyo3(signature=(path, comment=None, deliminator=None, labels=false), text_signature = "(path, /, comment=None, deliminator=None, labels=False)")] pub fn read_edge_list( From 5c39164065a8fabbcc445ec0fecbdad23925345e Mon Sep 17 00:00:00 2001 From: Mostafizur Date: Thu, 8 May 2025 17:04:18 +0530 Subject: [PATCH 2/8] remove unwanted changes --- src/graph.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graph.rs b/src/graph.rs index 8e3e45fd5f..d5942cb6ee 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1167,7 +1167,7 @@ impl PyGraph { #[pyo3(text_signature = "(self, node, /)")] pub fn adj(&mut self, node: usize) -> DictMap { let index = NodeIndex::new(node); - self.graphdel + self.graph .edges_directed(index, petgraph::Direction::Outgoing) .map(|edge| (edge.target().index(), edge.weight())) .collect() @@ -1368,6 +1368,7 @@ impl PyGraph { /// fd.write('2 3\n') /// fd.flush() /// graph = rx.PyGraph.read_edge_list(path=path) + /// mpl_draw(graph) /// /// For example for csv based data, you may use the below code /// From 7225a5eb62b1d9133b6eac731d6c6b2b60e92bb3 Mon Sep 17 00:00:00 2001 From: Mostafizur Rahaman Laskar <45648828+rahaman-quantum@users.noreply.github.com> Date: Thu, 8 May 2025 17:07:00 +0530 Subject: [PATCH 3/8] Update graph.rs --- src/graph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph.rs b/src/graph.rs index d5942cb6ee..e1441c9b45 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1368,7 +1368,7 @@ impl PyGraph { /// fd.write('2 3\n') /// fd.flush() /// graph = rx.PyGraph.read_edge_list(path=path) - /// mpl_draw(graph) + /// mpl_draw(graph) /// /// For example for csv based data, you may use the below code /// From 02b6c4e09cb56e03f4d4d6d36a5f2fee32928949 Mon Sep 17 00:00:00 2001 From: Mostafizur Rahaman Laskar <45648828+rahaman-quantum@users.noreply.github.com> Date: Fri, 9 May 2025 13:27:19 +0530 Subject: [PATCH 4/8] Update src/graph.rs Co-authored-by: Matthew Treinish --- src/graph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph.rs b/src/graph.rs index e1441c9b45..2f4d9e4205 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1370,7 +1370,7 @@ impl PyGraph { /// graph = rx.PyGraph.read_edge_list(path=path) /// mpl_draw(graph) /// - /// For example for csv based data, you may use the below code + /// For example for csv based data, you may use the below code:: /// /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") /// From 68543a1efd6ef4a1482d70d4d5073cdc8bb84855 Mon Sep 17 00:00:00 2001 From: Mostafizur Rahaman Laskar <45648828+rahaman-quantum@users.noreply.github.com> Date: Fri, 9 May 2025 17:32:12 +0530 Subject: [PATCH 5/8] Update graph.rs --- src/graph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph.rs b/src/graph.rs index 2f4d9e4205..e1441c9b45 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1370,7 +1370,7 @@ impl PyGraph { /// graph = rx.PyGraph.read_edge_list(path=path) /// mpl_draw(graph) /// - /// For example for csv based data, you may use the below code:: + /// For example for csv based data, you may use the below code /// /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") /// From 18c65eb91580bf8ee1fd4e59d6af523c4f1b09a7 Mon Sep 17 00:00:00 2001 From: Mostafizur Date: Fri, 9 May 2025 17:42:57 +0530 Subject: [PATCH 6/8] pul correct version --- src/graph.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index e1441c9b45..5059157fb5 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1371,13 +1371,17 @@ impl PyGraph { /// mpl_draw(graph) /// /// For example for csv based data, you may use the below code +<<<<<<< HEAD /// +======= + /// +>>>>>>> 4320ceb (fmt changes) /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") - /// + /// /// Data with labels for nodes - /// + /// /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",",labels=True) - /// + /// #[staticmethod] #[pyo3(signature=(path, comment=None, deliminator=None, labels=false), text_signature = "(path, /, comment=None, deliminator=None, labels=False)")] pub fn read_edge_list( From bc8444f649bd9c583be33128d535adf0e0cc529f Mon Sep 17 00:00:00 2001 From: Mostafizur Date: Fri, 9 May 2025 17:45:26 +0530 Subject: [PATCH 7/8] fmt fix --- src/graph.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index 5059157fb5..657fac8d88 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1371,11 +1371,6 @@ impl PyGraph { /// mpl_draw(graph) /// /// For example for csv based data, you may use the below code -<<<<<<< HEAD - /// -======= - /// ->>>>>>> 4320ceb (fmt changes) /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") /// /// Data with labels for nodes From 74f8b2ad776cef51097e15ee0ced56a953e5234a Mon Sep 17 00:00:00 2001 From: Mostafizur Date: Fri, 9 May 2025 18:03:35 +0530 Subject: [PATCH 8/8] added example for read_edge_list function --- src/graph.rs | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index 657fac8d88..705c43b47b 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1370,12 +1370,42 @@ impl PyGraph { /// graph = rx.PyGraph.read_edge_list(path=path) /// mpl_draw(graph) /// - /// For example for csv based data, you may use the below code - /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") + /// For example for csv based data, you may use the below code:: + /// + /// import rustworkx as rx + /// from rustworkx.visualization import mpl_draw + /// + /// file="/tmp/123.txt" + /// + /// with open(file,"w+") as fd: + /// fd.write('0,1,1.5\n') + /// fd.write('0,2,0.5\n') + /// fd.write('0,3,1\n') + /// fd.write('1,2,1\n') + /// fd.write('2,3,2\n') + /// fd.flush() + /// + /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",") + /// mpl_draw(graph) + /// + /// + /// For Labels Based Data:: + /// + /// import rustworkx as rx + /// from rustworkx.visualization import mpl_draw + /// + /// file="/tmp/123.txt" /// - /// Data with labels for nodes + /// with open(file,"w+") as fd: + /// fd.write('A,B,1.5\n') + /// fd.write('A,C,0.5\n') + /// fd.write('A,D,1\n') + /// fd.write('A,C,1\n') + /// fd.write('C,D,2\n') + /// fd.flush() /// - /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",",labels=True) + /// graph = rx.PyGraph.read_edge_list(path=file, deliminator=",", labels=True) + /// mpl_draw(graph) /// #[staticmethod] #[pyo3(signature=(path, comment=None, deliminator=None, labels=false), text_signature = "(path, /, comment=None, deliminator=None, labels=False)")]