Skip to content

Commit

Permalink
Add new graph structure (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iroy30 authored Apr 28, 2021
1 parent 9011eec commit cff84f5
Show file tree
Hide file tree
Showing 33 changed files with 2,239 additions and 1,575 deletions.
10 changes: 5 additions & 5 deletions benchmarks/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def createGraph(csvFileName, graphType=None):
# complexity lower, and assume tests have coverage to verify
# correctness for those combinations.
if "/directed/" in csvFileName:
graphType = cugraph.structure.graph.DiGraph
graphType = cugraph.structure.graph_classes.DiGraph
else:
graphType = cugraph.structure.graph.Graph
graphType = cugraph.structure.graph_classes.Graph

return cugraph.from_cudf_edgelist(
utils.read_csv_file(csvFileName),
Expand Down Expand Up @@ -122,7 +122,7 @@ def graphWithAdjListComputed(request):
csvFileName = request.param[0]
reinitRMM(request.param[1], request.param[2])

G = createGraph(csvFileName, cugraph.structure.graph.Graph)
G = createGraph(csvFileName, cugraph.structure.graph_classes.Graph)
G.view_adj_list()
return G

Expand Down Expand Up @@ -166,7 +166,7 @@ def bench_create_graph(gpubenchmark, edgelistCreated):
gpubenchmark(cugraph.from_cudf_edgelist,
edgelistCreated,
source="0", destination="1",
create_using=cugraph.structure.graph.Graph,
create_using=cugraph.structure.graph_classes.Graph,
renumber=False)


Expand All @@ -183,7 +183,7 @@ def bench_create_digraph(gpubenchmark, edgelistCreated):
gpubenchmark(cugraph.from_cudf_edgelist,
edgelistCreated,
source="0", destination="1",
create_using=cugraph.structure.graph.DiGraph,
create_using=cugraph.structure.graph_classes.DiGraph,
renumber=False)


Expand Down
8 changes: 7 additions & 1 deletion python/cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
DiGraph,
MultiGraph,
MultiDiGraph,
BiPartiteGraph,
BiPartiteDiGraph,
from_edgelist,
from_cudf_edgelist,
from_pandas_edgelist,
Expand All @@ -48,7 +50,11 @@
symmetrize,
symmetrize_df,
symmetrize_ddf,
)
is_weighted,
is_directed,
is_multigraph,
is_bipartite,
is_multipartite)

from cugraph.centrality import (
betweenness_centrality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# cython: language_level = 3

from cugraph.centrality.betweenness_centrality cimport betweenness_centrality as c_betweenness_centrality
from cugraph.structure.graph import DiGraph
from cugraph.structure.graph_classes import DiGraph
from cugraph.structure.graph_primtypes cimport *
from libc.stdint cimport uintptr_t
from libcpp cimport bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from cugraph.centrality.betweenness_centrality cimport edge_betweenness_centrality as c_edge_betweenness_centrality
from cugraph.structure import graph_primtypes_wrapper
from cugraph.structure.graph import DiGraph, Graph
from cugraph.structure.graph_classes import DiGraph, Graph
from cugraph.structure.graph_primtypes cimport *
from libc.stdint cimport uintptr_t
from libcpp cimport bool
Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/community/ktruss_subgraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.community import ktruss_subgraph_wrapper
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph
from cugraph.utilities import check_nx_graph
from cugraph.utilities import cugraph_to_nx

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/community/leiden.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 - 2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.community import leiden_wrapper
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph
from cugraph.utilities import check_nx_graph
from cugraph.utilities import df_score_to_dictionary

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/community/louvain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.community import louvain_wrapper
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph
from cugraph.utilities import check_nx_graph
from cugraph.utilities import df_score_to_dictionary

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/community/subgraph_extraction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.community import subgraph_extraction_wrapper
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check
from cugraph.utilities import check_nx_graph
from cugraph.utilities import cugraph_to_nx

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/community/triangle_count.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.community import triangle_count_wrapper
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph
from cugraph.utilities import check_nx_graph


Expand Down
2 changes: 1 addition & 1 deletion python/cugraph/components/connectivity_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from cugraph.structure import utils_wrapper
from cugraph.structure import graph_primtypes_wrapper
from libc.stdint cimport uintptr_t
from cugraph.structure.symmetrize import symmetrize
from cugraph.structure.graph import Graph as type_Graph
from cugraph.structure.graph_classes import Graph as type_Graph
import cudf
import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/cores/k_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -14,7 +14,7 @@
from cugraph.cores import k_core_wrapper, core_number_wrapper
from cugraph.utilities import cugraph_to_nx
from cugraph.utilities import check_nx_graph
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph


def k_core(G, k=None, core_number=None):
Expand Down
2 changes: 1 addition & 1 deletion python/cugraph/dask/link_analysis/pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def pagerank(input_graph,
edge_attr='value')
>>> pr = dcg.pagerank(dg)
"""
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check

nstart = None

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/layout/force_atlas2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020, NVIDIA CORPORATION.
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.layout import force_atlas2_wrapper
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check


def force_atlas2(
Expand Down
2 changes: 1 addition & 1 deletion python/cugraph/link_analysis/pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.link_analysis import pagerank_wrapper
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check
import cugraph


Expand Down
5 changes: 2 additions & 3 deletions python/cugraph/link_prediction/jaccard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -13,9 +13,8 @@

import pandas as pd
import cudf
from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph, null_check
from cugraph.link_prediction import jaccard_wrapper
from cugraph.structure.graph import null_check
from cugraph.utilities import check_nx_graph
from cugraph.utilities import df_edge_score_to_dictionary

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/link_prediction/overlap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -13,7 +13,7 @@

import pandas as pd
from cugraph.link_prediction import overlap_wrapper
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check
import cudf
from cugraph.utilities import check_nx_graph
from cugraph.utilities import df_edge_score_to_dictionary
Expand Down
5 changes: 2 additions & 3 deletions python/cugraph/link_prediction/wjaccard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -11,9 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from cugraph.structure.graph import Graph
from cugraph.structure.graph_classes import Graph, null_check
from cugraph.link_prediction import jaccard_wrapper
from cugraph.structure.graph import null_check
import cudf


Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/link_prediction/woverlap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
# limitations under the License.

from cugraph.link_prediction import overlap_wrapper
from cugraph.structure.graph import null_check
from cugraph.structure.graph_classes import null_check
import cudf


Expand Down
14 changes: 12 additions & 2 deletions python/cugraph/structure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -11,7 +11,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from cugraph.structure.graph import Graph, DiGraph, MultiGraph, MultiDiGraph
from cugraph.structure.graph_classes import (Graph,
DiGraph,
MultiGraph,
MultiDiGraph,
BiPartiteGraph,
BiPartiteDiGraph)
from cugraph.structure.graph_classes import (is_weighted,
is_directed,
is_multigraph,
is_bipartite,
is_multipartite)
from cugraph.structure.number_map import NumberMap
from cugraph.structure.symmetrize import symmetrize, symmetrize_df , symmetrize_ddf
from cugraph.structure.convert_matrix import (from_edgelist,
Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/structure/convert_matrix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -18,7 +18,7 @@
import cudf
import dask_cudf

from cugraph.structure.graph import DiGraph, Graph
from cugraph.structure.graph_classes import DiGraph, Graph

# optional dependencies used for handling different input types
try:
Expand Down
Loading

0 comments on commit cff84f5

Please sign in to comment.