def test_assign_node_centroids(self): G1 = simple_weighted_graph() mkg.assign_node_centroids(G1, [(1, 0, 0), (0, 1, 0), (0, 0, 1)]) assert nx.is_isomorphic( G1, self.Gcentroids, edge_match=em(), node_match=nm(exclude=['name', "name_34", "name_68", "hemi"]))
def setUpClass(self): self.no_centroids = nx.karate_club_graph() self.identical_centroids = nx.karate_club_graph() mkg.assign_node_centroids(self.identical_centroids, [(-1, 0, 0) for x in self.no_centroids.nodes]) self.opposing_centroids = nx.complete_graph(6) mkg.assign_node_centroids(self.opposing_centroids, [((-1)**i, 0, 0) for i in self.no_centroids.nodes])
def set_centroids(self, centroids): ''' Modify the nodal attributes "centroids", "x", "y", and "z" of nodes of G inplace. Parameters ---------- G : :class:`networkx.Graph` centroids : list ``centroids[i]`` is a tuple representing the cartesian coordinates of node ``i`` in ``G``. "x", "y" and "z" will be assigned as the first, second and third coordinate of ``centroids[i]`` respectively. See Also -------- :func:`BrainNetwork.calculate_spatial_measures` :func:`BrainNetwork.set_parcellation` :func:`assign_node_centroids` ''' assign_node_centroids(self, centroids)
def simple_anatomical_graph(): G = simple_weighted_graph() mkg.assign_node_centroids(G, [(1, 0, 0), (0, 1, 0), (0, 0, 1)]) mkg.assign_node_names(G, ['a', 'b', 'c']) return G