Skip to content

Commit

Permalink
[Hetero][RFC] Heterogeneous graph Python interfaces & Message Passing (
Browse files Browse the repository at this point in the history
…dmlc#752)

* moving heterograph index to another file

* node view

* python interfaces

* heterograph init

* bug fixes

* docstring for readonly

* more docstring

* unit tests & lint

* oops

* oops x2

* removed node/edge addition

* addressed comments

* lint

* rw on frames with one node/edge type

* homograph with underlying heterograph demo

* view is not necessary

* bugfix

* replace

* scheduler, builtins not working yet

* moving bipartite.h to header

* moving back bipartite to bipartite.h

* oops

* asbits and copyto for bipartite

* tested update_all and send_and_recv

* lightweight node & edge type retrieval

* oops

* sorry

* removing obsolete code

* oops

* lint

* various bug fixes & more tests

* UDF tests

* multiple type number_of_nodes and number_of_edges

* docstring fixes

* more tests

* going for dict in initialization

* lint

* updated api as per discussions

* lint

* bug

* bugfix

* moving back bipartite impl to cc

* note on views

* fix
  • Loading branch information
BarclayII authored and jermainewang committed Aug 23, 2019
1 parent 66971c1 commit 52d4535
Show file tree
Hide file tree
Showing 22 changed files with 2,970 additions and 1,898 deletions.
5 changes: 5 additions & 0 deletions include/dgl/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ IdArray IndexSelect(IdArray array, IdArray index);
*/
IdArray Relabel_(const std::vector<IdArray>& arrays);

/*!\brief Return whether the array is a valid 1D int array*/
inline bool IsValidIdArray(const dgl::runtime::NDArray& arr) {
return arr->ndim == 1 && arr->dtype.code == kDLInt;
}

//////////////////////////////////////////////////////////////////////
// Sparse matrix
//////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions python/dgl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .backend import load_backend
from .batched_graph import *
from .graph import DGLGraph
from .heterograph import DGLHeteroGraph
from .nodeflow import *
from .traversal import *
from .transform import *
Expand Down
20 changes: 20 additions & 0 deletions python/dgl/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ def number_of_nodes(self):
"""
return self._graph.number_of_nodes()

def _number_of_src_nodes(self):
"""Return number of source nodes (only used in scheduler)"""
return self.number_of_nodes()

def _number_of_dst_nodes(self):
"""Return number of destination nodes (only used in scheduler)"""
return self.number_of_nodes()

def __len__(self):
"""Return the number of nodes in the graph."""
return self.number_of_nodes()
Expand All @@ -65,6 +73,10 @@ def is_readonly(self):
"""
return self._graph.is_readonly()

def _number_of_edges(self):
"""Return number of edges in the current view (only used for scheduler)"""
return self.number_of_edges()

def number_of_edges(self):
"""Return the number of edges in the graph.
Expand Down Expand Up @@ -939,6 +951,14 @@ def _get_msg_index(self):
def _set_msg_index(self, index):
self._msg_index = index

@property
def _src_frame(self):
return self._node_frame

@property
def _dst_frame(self):
return self._node_frame

def add_nodes(self, num, data=None):
"""Add multiple new nodes.
Expand Down
Loading

0 comments on commit 52d4535

Please sign in to comment.