From 53384eea819c9b1894f0371fe1923da2df6ec50f Mon Sep 17 00:00:00 2001 From: Justin Luke Date: Thu, 12 Dec 2019 22:02:33 -0800 Subject: [PATCH 1/3] Added suggestions to todo.txt. Adjacency and incidence matrices would be very useful for future student projects. --- doc/todo.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/todo.txt b/doc/todo.txt index 8daca5b0..5ed8a40c 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -15,3 +15,6 @@ Apr 20, 2016 - Implement a method in TNEANet to return a list of edges between two nodes +- Implement a method in all graph types to return the graph adjacency matrix + +- Implement a method in all graph types to return the graph incidence matrix From 54d857ad7b895bbf23f4f72b12238b3c7e0a1f52 Mon Sep 17 00:00:00 2001 From: Justin Luke Date: Thu, 12 Dec 2019 22:03:04 -0800 Subject: [PATCH 2/3] Added suggestions to todo.txt. Adjacency and incidence matrices would be very useful for future student projects. --- doc/todo.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 5ed8a40c..6c9e01a2 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -15,6 +15,6 @@ Apr 20, 2016 - Implement a method in TNEANet to return a list of edges between two nodes -- Implement a method in all graph types to return the graph adjacency matrix +- Implement a method in all graph types to return the graph adjacency matrix as a sparse matrix -- Implement a method in all graph types to return the graph incidence matrix +- Implement a method in all graph types to return the graph incidence matrix as a sparse matrix From 13c580f6dace9ad87d26acf9f40b24931e9352ff Mon Sep 17 00:00:00 2001 From: Justin Luke Date: Thu, 12 Dec 2019 22:05:25 -0800 Subject: [PATCH 3/3] Modified the node iterator example to make use of the "useful methods" listed. Also added description for GetOutEdges()/GetInEdges(), especially since their names are misleading (returns generator of int node ids, not Edge iterators). --- doc/source/tutorial/tutorial.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/source/tutorial/tutorial.rst b/doc/source/tutorial/tutorial.rst index 7a3f626e..cc29eedc 100644 --- a/doc/source/tutorial/tutorial.rst +++ b/doc/source/tutorial/tutorial.rst @@ -309,11 +309,11 @@ Traverse all the edges using an edge iterator: >>> for EI in G2.Edges(): >>> print("edge (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())) -Traverse the edges by traversing nodes and getting all their neighbors: +Traverse the edges by traversing nodes and getting all their out-neighbors: >>> for NI in G2.Nodes(): ->>> for Id in NI.GetOutEdges(): ->>> print("edge (%d %d)" % (NI.GetId(), Id)) +>>> for e in range(NI.GetOutDeg()): +>>> print("edge (%d %d)" % (NI.GetId(), NI.GetOutNId(e))) Node iterators provide several useful methods: @@ -322,6 +322,8 @@ Node iterators provide several useful methods: * GetInDeg(): returns in-degree of a node * GetOutNId(e): returns node id of the endpoint of e-th out-edge * GetInNId(e): returns node id of the endpoint of e-th in-edge +* GetOutEdges(): returns generator of node ids of the endpoints of out-edges +* GetInEdges(): returns generator of node ids of the endpoints of in-edges * IsOutNId(n): tests if there is an out-edge to node n * IsInNId(n): tests if there is an in-edge from node n * IsNbrNId(n): tests if node n is a neighbor