MCPcopy
hub / github.com/dmlc/dgl / process

Method process

python/dgl/data/citation_graph.py:831–863  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

829 )
830
831 def process(self):
832 root = self.raw_path
833 # load graphs
834 self.graphs = []
835 with open("{}/graphs.txt".format(root), "r") as f:
836 elist = []
837 for line in f.readlines():
838 if line.startswith("graph"):
839 if len(elist) != 0:
840 self.graphs.append(dgl_graph(tuple(zip(*elist))))
841 elist = []
842 else:
843 u, v = line.strip().split(" ")
844 elist.append((int(u), int(v)))
845 if len(elist) != 0:
846 self.graphs.append(dgl_graph(tuple(zip(*elist))))
847 with open("{}/pmpds.pkl".format(root), "rb") as f:
848 self.pmpds = _pickle_load(f)
849 self.labels = []
850 with open("{}/labels.txt".format(root), "r") as f:
851 cur = []
852 for line in f.readlines():
853 if line.startswith("graph"):
854 if len(cur) != 0:
855 self.labels.append(np.asarray(cur))
856 cur = []
857 else:
858 cur.append(int(line.strip()))
859 if len(cur) != 0:
860 self.labels.append(np.asarray(cur))
861 # sanity check
862 assert len(self.graphs) == len(self.pmpds)
863 assert len(self.graphs) == len(self.labels)
864
865 @property
866 def graph_path(self):

Callers

nothing calls this directly

Calls 3

_pickle_loadFunction · 0.85
formatMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected