MCPcopy Create free account
hub / github.com/alibaba/GraphScope / test_update

Method test_update

python/graphscope/nx/tests/classes/test_graph.py:159–241  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

157 assert G[True][False]["weight"] == True
158
159 def test_update(self):
160 # specify both edges and nodes
161 G = self.K3.copy()
162 G.update(nodes=[3, (4, {"size": 2})], edges=[(4, 5), (6, 7, {"weight": 2})])
163 nlist = [
164 (0, {}),
165 (1, {}),
166 (2, {}),
167 (3, {}),
168 (4, {"size": 2}),
169 (5, {}),
170 (6, {}),
171 (7, {}),
172 ]
173 assert sorted(G.nodes.data()) == nlist
174 if G.is_directed():
175 elist = [
176 (0, 1, {}),
177 (0, 2, {}),
178 (1, 0, {}),
179 (1, 2, {}),
180 (2, 0, {}),
181 (2, 1, {}),
182 (4, 5, {}),
183 (6, 7, {"weight": 2}),
184 ]
185 else:
186 if os.environ.get("DEPLOYMENT", None) == "standalone":
187 elist = [
188 (0, 1, {}),
189 (0, 2, {}),
190 (1, 2, {}),
191 (4, 5, {}),
192 (6, 7, {"weight": 2}),
193 ]
194 else: # num_workers = 2
195 elist = [
196 (0, 2, {}),
197 (1, 0, {}),
198 (1, 2, {}),
199 (5, 4, {}),
200 (7, 6, {"weight": 2}),
201 ]
202 assert sorted(G.edges.data()) == elist
203 assert G.graph == {}
204
205 # no keywords -- order is edges, nodes
206 G = self.K3.copy()
207 G.update([(4, 5), (6, 7, {"weight": 2})], [3, (4, {"size": 2})])
208 assert sorted(G.nodes.data()) == nlist
209 assert sorted(G.edges.data()) == elist
210 assert G.graph == {}
211
212 # update using only a graph
213 G = self.Graph()
214 G.graph["foo"] = "bar"
215 G.add_node(2, data=4)
216 G.add_edge(0, 1, weight=0.5)

Callers

nothing calls this directly

Calls 9

updateMethod · 0.95
is_directedMethod · 0.95
add_nodeMethod · 0.95
add_edgeMethod · 0.95
copyMethod · 0.95
sizeMethod · 0.95
copyMethod · 0.65
dataMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected