Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] force_atlas2 to support nx hypercube_graph #1779

Merged
merged 4 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/cugraph/layout/force_atlas2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# limitations under the License.

from cugraph.layout import force_atlas2_wrapper
import cugraph


def force_atlas2(
Expand Down Expand Up @@ -106,6 +107,7 @@ def on_train_end(self, positions):
GPU data frame of size V containing three columns:
the vertex identifiers and the x and y positions.
"""
input_graph, isNx = cugraph.utilities.check_nx_graph(input_graph)

if pos_list is not None:
if input_graph.renumbered is True:
Expand Down
10 changes: 9 additions & 1 deletion python/cugraph/utilities/nx_factory.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 @@ -14,6 +14,7 @@
import cugraph
from .utils import import_optional
from cudf import from_pandas
import numpy as np

nx = import_optional("networkx")

Expand All @@ -35,6 +36,13 @@ def convert_from_nx(nxG, weight=None):
raise ValueError("nxG does not appear to be a NetworkX graph type")

pdf = nx.to_pandas_edgelist(nxG)
# Convert vertex columns to strings if they are not integers
# This allows support for any vertex input type
if pdf["source"].dtype not in [np.int32, np.int64] or \
rlratzel marked this conversation as resolved.
Show resolved Hide resolved
pdf["target"].dtype not in [np.int32, np.int64]:
pdf['source'] = pdf['source'].astype(str)
pdf['target'] = pdf['target'].astype(str)
rlratzel marked this conversation as resolved.
Show resolved Hide resolved

num_col = len(pdf.columns)

if num_col < 2:
Expand Down