Unverified Commit 411bcd7e authored by Da Zheng's avatar Da Zheng Committed by GitHub
Browse files

[BUGFIX] extand DGLGraph graph_data. (#632)

* enable tutorial test in CI.

* extand DGLGraph graph_data.

* update doc.

* Revert "enable tutorial test in CI."

This reverts commit cd774067180922bb6ae979bde4aecbffc61c8147.

* accept DGLGraph in graph store.
parent 2e9949d2
...@@ -52,7 +52,7 @@ def main(args): ...@@ -52,7 +52,7 @@ def main(args):
n_test_samples)) n_test_samples))
# create GCN model # create GCN model
g = data.graph g = dgl.DGLGraph(data.graph, readonly=True)
g.ndata['features'] = features g.ndata['features'] = features
g.ndata['labels'] = labels g.ndata['labels'] = labels
......
...@@ -292,10 +292,19 @@ class SharedMemoryStoreServer(object): ...@@ -292,10 +292,19 @@ class SharedMemoryStoreServer(object):
and store them in shared memory. The loaded graph can be identified by and store them in shared memory. The loaded graph can be identified by
the graph name in the input argument. the graph name in the input argument.
DGL graph accepts graph data of multiple formats:
* NetworkX graph,
* scipy matrix,
* DGLGraph.
If the input graph data is DGLGraph, the constructed DGLGraph only contains
its graph index.
Parameters Parameters
---------- ----------
graph_data : graph data graph_data : graph data
Data to initialize graph. Same as networkx's semantics. Data to initialize graph.
edge_dir : string edge_dir : string
the edge direction for the graph structure ("in" or "out") the edge direction for the graph structure ("in" or "out")
graph_name : string graph_name : string
...@@ -309,14 +318,14 @@ class SharedMemoryStoreServer(object): ...@@ -309,14 +318,14 @@ class SharedMemoryStoreServer(object):
""" """
def __init__(self, graph_data, edge_dir, graph_name, multigraph, num_workers, port): def __init__(self, graph_data, edge_dir, graph_name, multigraph, num_workers, port):
self.server = None self.server = None
if isinstance(graph_data, GraphIndex): if isinstance(graph_data, (GraphIndex, DGLGraph)):
graph_idx = graph_data self._graph = DGLGraph(graph_data, multigraph=multigraph, readonly=True)
else: else:
indptr, indices = _to_csr(graph_data, edge_dir, multigraph) indptr, indices = _to_csr(graph_data, edge_dir, multigraph)
graph_idx = from_csr(utils.toindex(indptr), utils.toindex(indices), graph_idx = from_csr(utils.toindex(indptr), utils.toindex(indices),
multigraph, edge_dir, _get_graph_path(graph_name)) multigraph, edge_dir, _get_graph_path(graph_name))
self._graph = DGLGraph(graph_idx, multigraph=multigraph, readonly=True)
self._graph = DGLGraph(graph_idx, multigraph=multigraph, readonly=True)
self._num_workers = num_workers self._num_workers = num_workers
self._graph_name = graph_name self._graph_name = graph_name
self._edge_dir = edge_dir self._edge_dir = edge_dir
...@@ -1046,10 +1055,19 @@ def create_graph_store_server(graph_data, graph_name, store_type, num_workers, ...@@ -1046,10 +1055,19 @@ def create_graph_store_server(graph_data, graph_name, store_type, num_workers,
After the server runs, the graph store clients can access the graph data After the server runs, the graph store clients can access the graph data
with the specified graph name. with the specified graph name.
DGL graph accepts graph data of multiple formats:
* NetworkX graph,
* scipy matrix,
* DGLGraph.
If the input graph data is DGLGraph, the constructed DGLGraph only contains
its graph index.
Parameters Parameters
---------- ----------
graph_data : graph data graph_data : graph data
Data to initialize graph. Same as networkx's semantics. Data to initialize graph.
graph_name : string graph_name : string
Define the name of the graph. Define the name of the graph.
store_type : string store_type : string
......
...@@ -756,10 +756,19 @@ class DGLGraph(DGLBaseGraph): ...@@ -756,10 +756,19 @@ class DGLGraph(DGLBaseGraph):
Node and edge features are stored as a dictionary from the feature name Node and edge features are stored as a dictionary from the feature name
to the feature data (in tensor). to the feature data (in tensor).
DGL graph accepts graph data of multiple formats:
* NetworkX graph,
* scipy matrix,
* DGLGraph.
If the input graph data is DGLGraph, the constructed DGLGraph only contains
its graph index.
Parameters Parameters
---------- ----------
graph_data : graph data, optional graph_data : graph data, optional
Data to initialize graph. Same as networkx's semantics. Data to initialize graph.
node_frame : FrameRef, optional node_frame : FrameRef, optional
Node feature storage. Node feature storage.
edge_frame : FrameRef, optional edge_frame : FrameRef, optional
...@@ -898,7 +907,10 @@ class DGLGraph(DGLBaseGraph): ...@@ -898,7 +907,10 @@ class DGLGraph(DGLBaseGraph):
multigraph=None, multigraph=None,
readonly=False): readonly=False):
# graph # graph
gidx = graph_index.create_graph_index(graph_data, multigraph, readonly) if isinstance(graph_data, DGLGraph):
gidx = graph_data._graph
else:
gidx = graph_index.create_graph_index(graph_data, multigraph, readonly)
super(DGLGraph, self).__init__(gidx) super(DGLGraph, self).__init__(gidx)
# node and edge frame # node and edge frame
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment