Skip to content

Commit

Permalink
Add 24 more generators
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Oct 24, 2023
1 parent b4fb8df commit 5365700
Show file tree
Hide file tree
Showing 6 changed files with 929 additions and 4 deletions.
24 changes: 24 additions & 0 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,47 @@
# BEGIN: functions
"barbell_graph",
"betweenness_centrality",
"bull_graph",
"caveman_graph",
"chvatal_graph",
"circular_ladder_graph",
"complete_graph",
"cubical_graph",
"cycle_graph",
"davis_southern_women_graph",
"desargues_graph",
"diamond_graph",
"dodecahedral_graph",
"edge_betweenness_centrality",
"empty_graph",
"florentine_families_graph",
"frucht_graph",
"heawood_graph",
"house_graph",
"house_x_graph",
"icosahedral_graph",
"is_isolate",
"isolates",
"karate_club_graph",
"krackhardt_kite_graph",
"ladder_graph",
"les_miserables_graph",
"lollipop_graph",
"louvain_communities",
"moebius_kantor_graph",
"null_graph",
"number_of_isolates",
"octahedral_graph",
"pappus_graph",
"path_graph",
"petersen_graph",
"sedgewick_maze_graph",
"star_graph",
"tetrahedral_graph",
"trivial_graph",
"truncated_cube_graph",
"truncated_tetrahedron_graph",
"tutte_graph",
"wheel_graph",
# END: functions
},
Expand Down
11 changes: 11 additions & 0 deletions python/nx-cugraph/nx_cugraph/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ def __len__(self) -> int:
# NetworkX graph methods #
##########################

@networkx_api
def add_nodes_from(self, nodes_for_adding: Iterable[NodeKey], **attr) -> None:
if self._N != 0:
raise NotImplementedError(
"add_nodes_from is not implemented for graph that already has nodes."
)
G = self.to_networkx_class()()
G.add_nodes_from(nodes_for_adding, **attr)
G = nxcg.from_networkx(G, preserve_node_attrs=True)
self._become(G)

@networkx_api
def clear(self) -> None:
self.edge_values.clear()
Expand Down
1 change: 1 addition & 0 deletions python/nx-cugraph/nx_cugraph/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
# limitations under the License.
from .classic import *
from .community import *
from .small import *
from .social import *
Loading

0 comments on commit 5365700

Please sign in to comment.