def view_edge_list(self): """ Display the edge list. Compute it if needed. Returns ------- source_col : cudf.Series This cudf.Series wraps a gdf_column of size E (E: number of edges). The gdf column contains the source index for each edge. Source indices are in the range [0, V) (V: number of vertices). Source indices must be 32 bit integers. dest_col : cudf.Series This cudf.Series wraps a gdf_column of size E (E: number of edges). The gdf column contains the destination index for each edge. Destination indices are in the range [0, V) (V: number of vertices). Destination indices must be 32 bit integers. value_col : cudf.Series or ``None`` This pointer is ``None`` for unweighted graphs. For weighted graphs, this cudf.Series wraps a gdf_column of size E (E: number of edges). The gdf column contains the weight value for each edge. The expected type of the gdf_column element is floating point number. """ source_col, dest_col, value_col = \ graph_wrapper.view_edge_list(self.graph_ptr) return source_col, dest_col, value_col
def view_edge_list(self): """ Display the edge list. Compute it if needed. Returns ------- edgelist_df : cudf.DataFrame This cudf.DataFrame wraps source, destination and weight gdf_column of size E (E: number of edges) The 'src' column contains the source index for each edge. Source indices are in the range [0, V) (V: number of vertices). The 'dst' column contains the destination index for each edge. Destination indices are in the range [0, V) (V: number of vertices). For weighted graphs, dataframe contains 'weight' column containing the weight value for each edge. """ if self.edgelist is None: graph_wrapper.view_edge_list(self) edgelist_df = self.edgelist.edgelist_df if self.renumbered: if isinstance(self.edgelist.renumber_map, cudf.DataFrame): df = cudf.DataFrame() ncols = len(self.edgelist.edgelist_df) - 2 unrnb_df_ = edgelist_df.merge(self.edgelist.renumber_map, left_on='src', right_on='id', how='left').drop(['id', 'src']) unrnb_df = unrnb_df_.merge(self.edgelist.renumber_map, left_on='dst', right_on='id', how='left').drop(['id', 'dst']) cols = unrnb_df.columns df = unrnb_df[[cols[ncols:], cols[0:ncols]]] else: df = cudf.DataFrame() for c in edgelist_df.columns: if c in ['src', 'dst']: df[c] = self.edgelist.renumber_map[edgelist_df[c]].\ reset_index(drop=True) else: df[c] = edgelist_df[c] return df else: return edgelist_df
def view_edge_list(self): """ Display the edge list. Compute it if needed. Returns ------- edgelist_df : cudf.DataFrame This cudf.DataFrame wraps source, destination and weight gdf_column of size E (E: number of edges) The 'src' column contains the source index for each edge. Source indices are in the range [0, V) (V: number of vertices). The 'dst' column contains the destination index for each edge. Destination indices are in the range [0, V) (V: number of vertices). For weighted graphs, dataframe contains 'weight' column containing the weight value for each edge. """ if self.edgelist is None: graph_wrapper.view_edge_list(self) df = self.edgelist.edgelist_df if self.renumbered: df['src'] = self.edgelist.renumber_map[df['src']] df['dst'] = self.edgelist.renumber_map[df['dst']] return df
def view_edge_list(self): """ Display the edge list. Compute it if needed. NOTE: If the graph is of type Graph() then the displayed undirected edges are the same as displayed by networkx Graph(), but the direction could be different i.e. an edge displayed by cugraph as (src, dst) could be displayed as (dst, src) by networkx. cugraph.Graph stores symmetrized edgelist internally. For displaying undirected edgelist for a Graph the upper trianglar matrix of the symmetrized edgelist is returned. networkx.Graph renumbers the input and stores the upper triangle of this renumbered input. Since the internal renumbering of networx and cugraph is different, the upper triangular matrix of networkx renumbered input may not be the same as cugraph's upper trianglar matrix of the symmetrized edgelist. Hence the displayed source and destination pairs in both will represent the same edge but node values could be swapped. Returns ------- edgelist_df : cudf.DataFrame This cudf.DataFrame wraps source, destination and weight gdf_column of size E (E: number of edges) The 'src' column contains the source index for each edge. Source indices are in the range [0, V) (V: number of vertices). The 'dst' column contains the destination index for each edge. Destination indices are in the range [0, V) (V: number of vertices). For weighted graphs, dataframe contains 'weight' column containing the weight value for each edge. """ if self.edgelist is None: graph_wrapper.view_edge_list(self) if type(self) is Graph: edgelist_df = self.edgelist.edgelist_df[self.edgelist.edgelist_df[ 'src'] <= self.edgelist.edgelist_df['dst']].\ reset_index(drop=True) self.edge_count = len(edgelist_df) else: edgelist_df = self.edgelist.edgelist_df if self.renumbered: if isinstance(self.edgelist.renumber_map, cudf.DataFrame): df = cudf.DataFrame() ncols = len(edgelist_df.columns) - 2 unrnb_df_ = edgelist_df.merge(self.edgelist.renumber_map, left_on='src', right_on='id', how='left').drop(['id', 'src']) unrnb_df = unrnb_df_.merge(self.edgelist.renumber_map, left_on='dst', right_on='id', how='left').drop(['id', 'dst']) cols = unrnb_df.columns.to_list() df = unrnb_df[cols[ncols:] + cols[0:ncols]] else: df = cudf.DataFrame() for c in edgelist_df.columns: if c in ['src', 'dst']: df[c] = self.edgelist.renumber_map[edgelist_df[c]].\ reset_index(drop=True) else: df[c] = edgelist_df[c] return df else: return edgelist_df