Plotter Base

class graphistry.PlotterBase.PlotterBase(*args, **kwargs)

Bases: graphistry.Plottable.Plottable

Graph plotting class.

Created using Graphistry.bind().

Chained calls successively add data and visual encodings, and end with a plot call.

To streamline reuse and replayable notebooks, Plotter manipulations are immutable. Each chained call returns a new instance that derives from the previous one. The old plotter or the new one can then be used to create different graphs.

When using memoization, for .register(api=3) sessions with .plot(memoize=True), Pandas/cudf arrow coercions are memoized, and file uploads are skipped on same-hash dataframes.

The class supports convenience methods for mixing calls across Pandas, NetworkX, and IGraph.

Parameters
  • args (Any) –

  • kwargs (Any) –

addStyle(fg=None, bg=None, page=None, logo=None)

Set general visual styles

See .bind() and .settings(url_params={}) for additional styling options, and style() for another way to set the same attributes.

To facilitate reuse and replayable notebooks, the addStyle() call is chainable. Invocation does not effect the old style: it instead returns a new Plotter instance with the new styles added to the existing ones. Both the old and new styles can then be used for different graphs.

addStyle() will extend the existing style settings, while style() will replace any in the same group

Parameters
  • fg (dict) – Dictionary {‘blendMode’: str} of any valid CSS blend mode

  • bg (dict) – Nested dictionary of page background properties. {‘color’: str, ‘gradient’: {‘kind’: str, ‘position’: str, ‘stops’: list }, ‘image’: { ‘url’: str, ‘width’: int, ‘height’: int, ‘blendMode’: str }

  • logo (dict) – Nested dictionary of logo properties. { ‘url’: str, ‘autoInvert’: bool, ‘position’: str, ‘dimensions’: { ‘maxWidth’: int, ‘maxHeight’: int }, ‘crop’: { ‘top’: int, ‘left’: int, ‘bottom’: int, ‘right’: int }, ‘padding’: { ‘top’: int, ‘left’: int, ‘bottom’: int, ‘right’: int}, ‘style’: str}

  • page (dict) – Dictionary of page metadata settings. { ‘favicon’: str, ‘title’: str }

Returns

Plotter

Return type

Plotter

Example: Chained merge - results in color, blendMode, and url being set
g2 =  g.addStyle(bg={'color': 'black'}, fg={'blendMode': 'screen'})
g3 = g2.addStyle(bg={'image': {'url': 'http://site.com/watermark.png'}})
Example: Overwrite - results in blendMode multiply
g2 =  g.addStyle(fg={'blendMode': 'screen'})
g3 = g2.addStyle(fg={'blendMode': 'multiply'})
Example: Gradient background
g.addStyle(bg={'gradient': {'kind': 'linear', 'position': 45, 'stops': [['rgb(0,0,0)', '0%'], ['rgb(255,255,255)', '100%']]}})
Example: Page settings
g.addStyle(page={'title': 'Site - {{ name }}', 'favicon': 'http://site.com/logo.ico'})
bind(source=None, destination=None, node=None, edge=None, edge_title=None, edge_label=None, edge_color=None, edge_weight=None, edge_size=None, edge_opacity=None, edge_icon=None, edge_source_color=None, edge_destination_color=None, point_title=None, point_label=None, point_color=None, point_weight=None, point_size=None, point_opacity=None, point_icon=None, point_x=None, point_y=None)

Relate data attributes to graph structure and visual representation. To facilitate reuse and replayable notebooks, the binding call is chainable. Invocation does not effect the old binding: it instead returns a new Plotter instance with the new bindings added to the existing ones. Both the old and new bindings can then be used for different graphs.

Parameters
  • source (str) – Attribute containing an edge’s source ID

  • destination (str) – Attribute containing an edge’s destination ID

  • node (str) – Attribute containing a node’s ID

  • edge (str) – Attribute containing an edge’s ID

  • edge_title (str) – Attribute overriding edge’s minimized label text. By default, the edge source and destination is used.

  • edge_label (str) – Attribute overriding edge’s expanded label text. By default, scrollable list of attribute/value mappings.

  • edge_color (str) – Attribute overriding edge’s color. rgba (int64) or int32 palette index, see palette definitions for values. Based on Color Brewer.

  • edge_source_color (str) – Attribute overriding edge’s source color if no edge_color, as an rgba int64 value.

  • edge_destination_color (str) – Attribute overriding edge’s destination color if no edge_color, as an rgba int64 value.

  • edge_weight (str) – Attribute overriding edge weight. Default is 1. Advanced layout controls will relayout edges based on this value.

  • point_title (str) – Attribute overriding node’s minimized label text. By default, the node ID is used.

  • point_label (str) – Attribute overriding node’s expanded label text. By default, scrollable list of attribute/value mappings.

  • point_color (str) –

    Attribute overriding node’s color.rgba (int64) or int32 palette index, see palette definitions for values. Based on Color Brewer.

  • point_size (str) – Attribute overriding node’s size. By default, uses the node degree. The visualization will normalize point sizes and adjust dynamically using semantic zoom.

  • point_x (str) – Attribute overriding node’s initial x position. Combine with “.settings(url_params={‘play’: 0}))” to create a custom layout

  • point_y (str) – Attribute overriding node’s initial y position. Combine with “.settings(url_params={‘play’: 0}))” to create a custom layout

Returns

Plotter

Return type

Plotter

Example: Minimal

import graphistry
g = graphistry.bind()
g = g.bind(source='src', destination='dst')

Example: Node colors

import graphistry
g = graphistry.bind()
g = g.bind(source='src', destination='dst',
           node='id', point_color='color')

Example: Chaining

import graphistry
g = graphistry.bind(source='src', destination='dst', node='id')

g1 = g.bind(point_color='color1', point_size='size1')

g.bind(point_color='color1b')

g2a = g1.bind(point_color='color2a')
g2b = g1.bind(point_color='color2b', point_size='size2b')

g3a = g2a.bind(point_size='size3a')
g3b = g2b.bind(point_size='size3b')

In the above Chaining example, all bindings use src/dst/id. Colors and sizes bind to:

g: default/default
g1: color1/size1
g2a: color2a/size1
g2b: color2b/size2b
g3a: color2a/size3a
g3b: color2b/size3b
bolt(driver)
compute_cugraph(alg, out_col=None, params={}, kind='Graph', directed=True, G=None)

Run cugraph algorithm on graph. For algorithm parameters, see cuGraph docs.

Parameters
  • alg (str) – algorithm name

  • out_col (Optional[str]) – node table output column name, defaults to alg param

  • params (dict) – algorithm parameters passed to cuGraph as kwargs

  • kind (CuGraphKind) – kind of cugraph to use

  • directed (bool) – whether graph is directed

  • G (Optional[cugraph.Graph]) – cugraph graph to use; if None, use self

Returns

Plottable

Return type

Plottable

Example: Pagerank
g2 = g.compute_cugraph('pagerank')
assert 'pagerank' in g2._nodes.columns
Example: Katz centrality with rename
g2 = g.compute_cugraph('katz_centrality', out_col='katz_centrality_renamed')
assert 'katz_centrality_renamed' in g2._nodes.columns
Example: Pass params to cugraph
g2 = g.compute_cugraph('k_truss', params={'k': 2})
assert 'k_truss' in g2._nodes.columns
compute_igraph(alg, out_col=None, directed=None, use_vids=False, params={}, stringify_rich_types=True)

Enrich or replace graph using igraph methods

Parameters
  • alg (str) – Name of an igraph.Graph method like pagerank

  • out_col (Optional[str]) – For algorithms that generate a node attribute column, out_col is the desired output column name. When None, use the algorithm’s name. (default None)

  • directed (Optional[bool]) – During the to_igraph conversion, whether to be directed. If None, try directed and then undirected. (default None)

  • use_vids (bool) – During the to_igraph conversion, whether to interpret IDs as igraph vertex IDs (non-negative integers) or arbitrary values (False, default)

  • params (dict) – Any named parameters to pass to the underlying igraph method

  • stringify_rich_types (bool) – When rich types like igraph.Graph are returned, which may be problematic for downstream rendering, coerce them to strings

Returns

Plotter

Return type

Plotter

Example: Pagerank
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['c','c','e','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.compute_igraph('pagerank')
assert 'pagerank' in g2._nodes.columns
Example: Pagerank with custom name
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['c','c','e','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.compute_igraph('pagerank', out_col='my_pr')
assert 'my_pr' in g2._nodes.columns
Example: Pagerank on an undirected
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['c','c','e','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.compute_igraph('pagerank', directed=False)
assert 'pagerank' in g2._nodes.columns
Example: Pagerank with custom parameters
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['c','c','e','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.compute_igraph('pagerank', params={'damping': 0.85})
assert 'pagerank' in g2._nodes.columns
copy()
Return type

Plottable

cypher(query, params={})
description(description)

Upload description

Parameters

description (str) – Upload description

edges(edges, source=None, destination=None, edge=None, *args, **kwargs)

Specify edge list data and associated edge attribute values. If a callable, will be called with current Plotter and whatever positional+named arguments

Parameters

edges (Pandas dataframe, NetworkX graph, or IGraph graph) – Edges and their attributes, or transform from Plotter to edges

Returns

Plotter

Return type

Plotter

Example
import graphistry
df = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
graphistry
    .bind(source='src', destination='dst')
    .edges(df)
    .plot()
Example
import graphistry
df = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0], 'id': [0, 1, 2]})
graphistry
    .bind(source='src', destination='dst', edge='id')
    .edges(df)
    .plot()
Example
import graphistry
df = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
graphistry
    .edges(df, 'src', 'dst')
    .plot()
Example
import graphistry
df = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0], 'id': [0, 1, 2]})
graphistry
    .edges(df, 'src', 'dst', 'id')
    .plot()
Example
import graphistry

def sample_edges(g, n):
    return g._edges.sample(n)

df = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})

graphistry
    .edges(df, 'src', 'dst')
    .edges(sample_edges, n=2)
    .edges(sample_edges, None, None, None, 2)  # equivalent
    .plot()
encode_axis(rows=[])

Render radial and linear axes with optional labels

Parameters

rows – List of rows - { label: Optional[str],?r: float, ?x: float, ?y: float, ?internal: true, ?external: true, ?space: true }

Returns

Plotter

Return type

Plotter

Example: Several radial axes
g.encode_axis([
  {'r': 14, 'external': True, 'label': 'outermost'},
  {'r': 12, 'external': True},
  {'r': 10, 'space': True},
  {'r': 8, 'space': True},
  {'r': 6, 'internal': True},
  {'r': 4, 'space': True},
  {'r': 2, 'space': True, 'label': 'innermost'}
])
Example: Several horizontal axes
g.encode_axis([
  {"label": "a",  "y": 2, "internal": True },
  {"label": "b",  "y": 40, "external": True, "width": 20, "bounds": {"min": 40, "max": 400}},
])
encode_edge_badge(column, position='TopRight', categorical_mapping=None, continuous_binning=None, default_mapping=None, comparator=None, color=None, bg=None, fg=None, for_current=False, for_default=True, as_text=None, blend_mode=None, style=None, border=None, shape=None)
encode_edge_color(column, palette=None, as_categorical=None, as_continuous=None, categorical_mapping=None, default_mapping=None, for_default=True, for_current=False)

Set edge color with more control than bind()

Parameters
  • column (str) – Data column name

  • palette (Optional[list]) – Optional list of color-like strings. Ex: [“black, “#FF0”, “rgb(255,255,255)” ]. Used as a gradient for continuous and round-robin for categorical.

  • as_categorical (Optional[bool]) – Interpret column values as categorical. Ex: Uses palette via round-robin when more values than palette entries.

  • as_continuous (Optional[bool]) – Interpret column values as continuous. Ex: Uses palette for an interpolation gradient when more values than palette entries.

  • categorical_mapping (Optional[dict]) – Mapping from column values to color-like strings. Ex: {“car”: “red”, “truck”: #000”}

  • default_mapping (Optional[str]) – Augment categorical_mapping with mapping for values not in categorical_mapping. Ex: default_mapping=”gray”.

  • for_default (Optional[bool]) – Use encoding for when no user override is set. Default on.

  • for_current (Optional[bool]) – Use encoding as currently active. Clearing the active encoding resets it to default, which may be different. Default on.

Returns

Plotter

Return type

Plotter

Example: See encode_point_color

encode_edge_icon(column, categorical_mapping=None, continuous_binning=None, default_mapping=None, comparator=None, for_default=True, for_current=False, as_text=False, blend_mode=None, style=None, border=None, shape=None)

Set edge icon with more control than bind() Values from Font Awesome 4 such as “laptop”: https://fontawesome.com/v4.7.0/icons/ , image URLs (http://…), and data URIs (data:…). When as_text=True is enabled, values are instead interpreted as raw strings.

Parameters
  • column (str) – Data column name

  • categorical_mapping (Optional[dict]) – Mapping from column values to icon name strings. Ex: {“toyota”: ‘car’, “ford”: ‘truck’}

  • default_mapping (Optional[Union[int,float]]) – Augment categorical_mapping with mapping for values not in categorical_mapping. Ex: default_mapping=50.

  • for_default (Optional[bool]) – Use encoding for when no user override is set. Default on.

  • for_current (Optional[bool]) – Use encoding as currently active. Clearing the active encoding resets it to default, which may be different. Default on.

  • as_text (Optional[bool]) – Values should instead be treated as raw strings, instead of icons and images. (Default False.)

Returns

Plotter

Return type

Plotter

Example: Set a string column of icons for the edge icons, same as bind(edge_icon=’my_column’)
g2a = g.encode_edge_icon('my_icons_column')
Example: Map specific values to specific icons, including with a default
g2a = g.encode_edge_icon('brands', categorical_mapping={'toyota': 'car', 'ford': 'truck'})
g2b = g.encode_edge_icon('brands', categorical_mapping={'toyota': 'car', 'ford': 'truck'}, default_mapping='question')
Example: Map countries to abbreviations
g2a = g.encode_edge_icon('country_abbrev', as_text=True)
g2b = g.encode_edge_icon('country', as_text=True, categorical_mapping={'England': 'UK', 'America': 'US'}, default_mapping='')
Example: Border
g2b = g.encode_edge_icon('country', border={'width': 3, color: 'black', 'stroke': 'dashed'}, 'categorical_mapping={'England': 'UK', 'America': 'US'})
encode_point_badge(column, position='TopRight', categorical_mapping=None, continuous_binning=None, default_mapping=None, comparator=None, color=None, bg=None, fg=None, for_current=False, for_default=True, as_text=None, blend_mode=None, style=None, border=None, shape=None)
encode_point_color(column, palette=None, as_categorical=None, as_continuous=None, categorical_mapping=None, default_mapping=None, for_default=True, for_current=False)

Set point color with more control than bind()

Parameters
  • column (str) – Data column name

  • palette (Optional[list]) – Optional list of color-like strings. Ex: [“black, “#FF0”, “rgb(255,255,255)” ]. Used as a gradient for continuous and round-robin for categorical.

  • as_categorical (Optional[bool]) – Interpret column values as categorical. Ex: Uses palette via round-robin when more values than palette entries.

  • as_continuous (Optional[bool]) – Interpret column values as continuous. Ex: Uses palette for an interpolation gradient when more values than palette entries.

  • categorical_mapping (Optional[dict]) – Mapping from column values to color-like strings. Ex: {“car”: “red”, “truck”: #000”}

  • default_mapping (Optional[str]) – Augment categorical_mapping with mapping for values not in categorical_mapping. Ex: default_mapping=”gray”.

  • for_default (Optional[bool]) – Use encoding for when no user override is set. Default on.

  • for_current (Optional[bool]) – Use encoding as currently active. Clearing the active encoding resets it to default, which may be different. Default on.

Returns

Plotter

Return type

Plotter

Example: Set a palette-valued column for the color, same as bind(point_color=’my_column’)
g2a = g.encode_point_color('my_int32_palette_column')
g2b = g.encode_point_color('my_int64_rgb_column')
Example: Set a cold-to-hot gradient of along the spectrum blue, yellow, red
g2 = g.encode_point_color('my_numeric_col', palette=["blue", "yellow", "red"], as_continuous=True)
Example: Round-robin sample from 5 colors in hex format
g2 = g.encode_point_color('my_distinctly_valued_col', palette=["#000", "#00F", "#0F0", "#0FF", "#FFF"], as_categorical=True)
Example: Map specific values to specific colors, including with a default
g2a = g.encode_point_color('brands', categorical_mapping={'toyota': 'red', 'ford': 'blue'})
g2a = g.encode_point_color('brands', categorical_mapping={'toyota': 'red', 'ford': 'blue'}, default_mapping='gray')
encode_point_icon(column, categorical_mapping=None, continuous_binning=None, default_mapping=None, comparator=None, for_default=True, for_current=False, as_text=False, blend_mode=None, style=None, border=None, shape=None)

Set node icon with more control than bind(). Values from Font Awesome 4 such as “laptop”: https://fontawesome.com/v4.7.0/icons/ , image URLs (http://…), and data URIs (data:…). When as_text=True is enabled, values are instead interpreted as raw strings.

Parameters
  • column (str) – Data column name

  • categorical_mapping (Optional[dict]) – Mapping from column values to icon name strings. Ex: {“toyota”: ‘car’, “ford”: ‘truck’}

  • default_mapping (Optional[Union[int,float]]) – Augment categorical_mapping with mapping for values not in categorical_mapping. Ex: default_mapping=50.

  • for_default (Optional[bool]) – Use encoding for when no user override is set. Default on.

  • for_current (Optional[bool]) – Use encoding as currently active. Clearing the active encoding resets it to default, which may be different. Default on.

  • as_text (Optional[bool]) – Values should instead be treated as raw strings, instead of icons and images. (Default False.)

  • blend_mode (Optional[str]) – CSS blend mode

  • style (Optional[dict]) – CSS filter properties - opacity, saturation, luminosity, grayscale, and more

  • border (Optional[dict]) – Border properties - ‘width’, ‘color’, and ‘storke’

Returns

Plotter

Return type

Plotter

Example: Set a string column of icons for the point icons, same as bind(point_icon=’my_column’)
g2a = g.encode_point_icon('my_icons_column')
Example: Map specific values to specific icons, including with a default
g2a = g.encode_point_icon('brands', categorical_mapping={'toyota': 'car', 'ford': 'truck'})
g2b = g.encode_point_icon('brands', categorical_mapping={'toyota': 'car', 'ford': 'truck'}, default_mapping='question')
Example: Map countries to abbreviations
g2b = g.encode_point_icon('country_abbrev', as_text=True)
g2b = g.encode_point_icon('country', as_text=True, categorical_mapping={'England': 'UK', 'America': 'US'}, default_mapping='')
Example: Border
g2b = g.encode_point_icon('country', border={'width': 3, color: 'black', 'stroke': 'dashed'}, 'categorical_mapping={'England': 'UK', 'America': 'US'})
encode_point_size(column, categorical_mapping=None, default_mapping=None, for_default=True, for_current=False)

Set point size with more control than bind()

Parameters
  • column (str) – Data column name

  • categorical_mapping (Optional[dict]) – Mapping from column values to numbers. Ex: {“car”: 100, “truck”: 200}

  • default_mapping (Optional[Union[int,float]]) – Augment categorical_mapping with mapping for values not in categorical_mapping. Ex: default_mapping=50.

  • for_default (Optional[bool]) – Use encoding for when no user override is set. Default on.

  • for_current (Optional[bool]) – Use encoding as currently active. Clearing the active encoding resets it to default, which may be different. Default on.

Returns

Plotter

Return type

Plotter

Example: Set a numerically-valued column for the size, same as bind(point_size=’my_column’)
g2a = g.encode_point_size('my_numeric_column')
Example: Map specific values to specific colors, including with a default
g2a = g.encode_point_size('brands', categorical_mapping={'toyota': 100, 'ford': 200})
g2b = g.encode_point_size('brands', categorical_mapping={'toyota': 100, 'ford': 200}, default_mapping=50)
from_cugraph(G, node_attributes=None, edge_attributes=None, load_nodes=True, load_edges=True, merge_if_existing=True)

If bound IDs, use the same IDs in the returned graph.

If non-empty nodes/edges, instead of returning G’s topology, use existing topology and merge in G’s attributes

Parameters
  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

  • load_nodes (bool) –

  • load_edges (bool) –

  • merge_if_existing (bool) –

from_igraph(ig, node_attributes=None, edge_attributes=None, load_nodes=True, load_edges=True, merge_if_existing=True)

Convert igraph object into Plotter

If base g has _node, _source, _destination definitions, use them

When merge_if_existing with preexisting nodes/edges df and shapes match ig, combine attributes

For merge_if_existing to work with edges, must set g._edge and have corresponding edge index attribute in igraph.Graph

Parameters
  • ig (igraph) – Source igraph object

  • node_attributes (Optional[List[str]]) – Subset of node attributes to load; None means all (default)

  • edge_attributes (Optional[List[str]]) – Subset of edge attributes to load; None means all (default)

  • load_nodes (bool) – Whether to load nodes dataframe (default True)

  • load_edges (bool) – Whether to load edges dataframe (default True)

  • merge_if_existing – Whether to merge with existing node/edge dataframes (default True)

  • merge_if_existing – bool

Returns

Plotter

Example: Convert from igraph, including all node/edge properties
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a', 'b', 'c', 'd'], 'd': ['b', 'c', 'd', 'e'], 'v': [101, 102, 103, 104]})
g = graphistry.edges(edges, 's', 'd').materialize_nodes().get_degrees()
assert 'degree' in g._nodes.columns
g2 = g.from_igraph(g.to_igraph())
assert len(g2._nodes.columns) == len(g._nodes.columns)
Example: Enrich from igraph, but only load in 1 node attribute
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a', 'b', 'c', 'd'], 'd': ['b', 'c', 'd', 'e'], 'v': [101, 102, 103, 104]})
g = graphistry.edges(edges, 's', 'd').materialize_nodes().get_degree()
assert 'degree' in g._nodes
ig = g.to_igraph(include_nodes=False)
assert 'degree' not in ig.vs
ig.vs['pagerank'] = ig.pagerank()
g2 = g.from_igraph(ig, load_edges=False, node_attributes=[g._node, 'pagerank'])
assert 'pagerank' in g2._nodes
asssert 'degree' in g2._nodes
graph(ig)

Specify the node and edge data.

Parameters

ig (Any) – NetworkX graph or an IGraph graph with node and edge attributes.

Returns

Plotter

Return type

Plotter

gsql(query, bindings={}, dry_run=False)

Run Tigergraph query in interpreted mode and return transformed Plottable

param query

Code to run

type query

str

param bindings

Mapping defining names of returned ‘edges’ and/or ‘nodes’, defaults to @@nodeList and @@edgeList

type bindings

Optional[dict]

param dry_run

Return target URL without running

type dry_run

bool

returns

Plotter

rtype

Plotter

Example: Minimal
import graphistry
tg = graphistry.tigergraph()
tg.gsql("""
INTERPRET QUERY () FOR GRAPH Storage { 

    OrAccum<BOOL> @@stop;
    ListAccum<EDGE> @@edgeList;
    SetAccum<vertex> @@set;

    @@set += to_vertex("61921", "Pool");

    Start = @@set;

    while Start.size() > 0 and @@stop == false do

    Start = select t from Start:s-(:e)-:t
    where e.goUpper == TRUE
    accum @@edgeList += e
    having t.type != "Service";
    end;

    print @@edgeList;
}
""").plot()
Example: Full
import graphistry
tg = graphistry.tigergraph()
tg.gsql("""
INTERPRET QUERY () FOR GRAPH Storage { 

    OrAccum<BOOL> @@stop;
    ListAccum<EDGE> @@edgeList;
    SetAccum<vertex> @@set;

    @@set += to_vertex("61921", "Pool");

    Start = @@set;

    while Start.size() > 0 and @@stop == false do

    Start = select t from Start:s-(:e)-:t
    where e.goUpper == TRUE
    accum @@edgeList += e
    having t.type != "Service";
    end;

    print @@my_edge_list;
}
""", {'edges': 'my_edge_list'}).plot()
gsql_endpoint(method_name, args={}, bindings={}, db=None, dry_run=False)

Invoke Tigergraph stored procedure at a user-definend endpoint and return transformed Plottable

Parameters
  • method_name (str) – Stored procedure name

  • args (Optional[dict]) – Named endpoint arguments

  • bindings (Optional[dict]) – Mapping defining names of returned ‘edges’ and/or ‘nodes’, defaults to @@nodeList and @@edgeList

  • db (Optional[str]) – Name of the database, defaults to value set in .tigergraph(…)

  • dry_run (bool) – Return target URL without running

Returns

Plotter

Return type

Plotter

Example: Minimal
import graphistry
tg = graphistry.tigergraph(db='my_db')
tg.gsql_endpoint('neighbors').plot()
Example: Full
import graphistry
tg = graphistry.tigergraph()
tg.gsql_endpoint('neighbors', {'k': 2}, {'edges': 'my_edge_list'}, 'my_db').plot()
Example: Read data
import graphistry
tg = graphistry.tigergraph()
out = tg.gsql_endpoint('neighbors')
(nodes_df, edges_df) = (out._nodes, out._edges)
hypergraph(raw_events, entity_types=None, opts={}, drop_na=True, drop_edge_attrs=False, verbose=True, direct=False, engine='pandas', npartitions=None, chunksize=None)

Transform a dataframe into a hypergraph.

Parameters
  • raw_events (pandas.DataFrame) – Dataframe to transform (pandas or cudf).

  • entity_types (Optional[list]) – Columns (strings) to turn into nodes, None signifies all

  • opts (dict) – See below

  • drop_edge_attrs (bool) – Whether to include each row’s attributes on its edges, defaults to False (include)

  • verbose (bool) – Whether to print size information

  • direct (bool) – Omit hypernode and instead strongly connect nodes in an event

  • engine (bool) – String (pandas, cudf, …) for engine to use

  • npartitions (Optional[int]) – For distributed engines, how many coarse-grained pieces to split events into

  • chunksize (Optional[int]) – For distributed engines, split events after chunksize rows

Create a graph out of the dataframe, and return the graph components as dataframes, and the renderable result Plotter. Hypergraphs reveal relationships between rows and between column values. This transform is useful for lists of events, samples, relationships, and other structured high-dimensional data.

Specify local compute engine by passing engine=’pandas’, ‘cudf’, ‘dask’, ‘dask_cudf’ (default: ‘pandas’). If events are not in that engine’s format, they will be converted into it.

The transform creates a node for every unique value in the entity_types columns (default: all columns). If direct=False (default), every row is also turned into a node. Edges are added to connect every table cell to its originating row’s node, or if direct=True, to the other nodes from the same row. Nodes are given the attribute ‘type’ corresponding to the originating column name, or in the case of a row, ‘EventID’. Options further control the transform, such column category definitions for controlling whether values reocurring in different columns should be treated as one node, or whether to only draw edges between certain column type pairs.

Consider a list of events. Each row represents a distinct event, and each column some metadata about an event. If multiple events have common metadata, they will be transitively connected through those metadata values. The layout algorithm will try to cluster the events together. Conversely, if an event has unique metadata, the unique metadata will turn into nodes that only have connections to the event node, and the clustering algorithm will cause them to form a ring around the event node.

Best practice is to set EVENTID to a row’s unique ID, SKIP to all non-categorical columns (or entity_types to all categorical columns), and CATEGORY to group columns with the same kinds of values.

To prevent creating nodes for null values, set drop_na=True. Some dataframe engines may have undesirable null handling, and recommend replacing None values with np.nan .

The optional opts={...} configuration options are:

  • ‘EVENTID’: Column name to inspect for a row ID. By default, uses the row index.

  • ‘CATEGORIES’: Dictionary mapping a category name to inhabiting columns. E.g., {‘IP’: [‘srcAddress’, ‘dstAddress’]}. If the same IP appears in both columns, this makes the transform generate one node for it, instead of one for each column.

  • ‘DELIM’: When creating node IDs, defines the separator used between the column name and node value

  • ‘SKIP’: List of column names to not turn into nodes. For example, dates and numbers are often skipped.

  • ‘EDGES’: For direct=True, instead of making all edges, pick column pairs. E.g., {‘a’: [‘b’, ‘d’], ‘d’: [‘d’]} creates edges between columns a->b and a->d, and self-edges d->d.

Returns

{‘entities’: DF, ‘events’: DF, ‘edges’: DF, ‘nodes’: DF, ‘graph’: Plotter}

Return type

dict

Example: Connect user<-row->boss

import graphistry
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df)
g = h['graph'].plot()

Example: Connect user->boss

import graphistry
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True)
g = h['graph'].plot()

Example: Connect user<->boss

import graphistry
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True, opts={'EDGES': {'user': ['boss'], 'boss': ['user']}})
g = h['graph'].plot()

Example: Only consider some columns for nodes

import graphistry
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, entity_types=['boss'])
g = h['graph'].plot()

Example: Collapse matching user::<id> and boss::<id> nodes into one person::<id> node

import graphistry
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, opts={'CATEGORIES': {'person': ['user', 'boss']}})
g = h['graph'].plot()

Example: Use cudf engine instead of pandas

import cudf, graphistry
users_gdf = cudf.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_gdf, engine='cudf')
g = h['graph'].plot()
Parameters
  • entity_types (Optional[List[str]]) –

  • opts (dict) –

  • drop_na (bool) –

  • drop_edge_attrs (bool) –

  • verbose (bool) –

  • direct (bool) –

  • engine (str) –

  • npartitions (Optional[int]) –

  • chunksize (Optional[int]) –

igraph2pandas(ig)

Under current bindings, transform an IGraph into a pandas edges dataframe and a nodes dataframe.

Deprecated in favor of .from_igraph()

Example
import graphistry
g = graphistry.bind()

es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
g = g.bind(source='src', destination='dst').edges(es)

ig = g.pandas2igraph(es)
ig.vs['community'] = ig.community_infomap().membership

(es2, vs2) = g.igraph2pandas(ig)
g.nodes(vs2).bind(point_color='community').plot()
infer_labels()
Returns

Plotter w/neo4j

  • Prefers point_title/point_label if available

  • Fallback to node id

  • Raises exception if no nodes available, no likely candidates, and no matching node id fallback

Example

import graphistry
g = graphistry.nodes(pd.read_csv('nodes.csv'), 'id_col').infer_labels()
g.plot()
layout_cugraph(layout='force_atlas2', params={}, kind='Graph', directed=True, G=None, bind_position=True, x_out_col='x', y_out_col='y', play=0)

Layout the grpah using a cuGraph algorithm. For a list of layouts, see cugraph documentation (currently just force_atlas2).

Parameters
  • layout (str) – Name of an cugraph layout method like force_atlas2

  • params (dict) – Any named parameters to pass to the underlying cugraph method

  • kind (CuGraphKind) – The kind of cugraph Graph

  • directed (bool) – During the to_cugraph conversion, whether to be directed. (default True)

  • G (Optional[Any]) – The cugraph graph (G) to layout. If None, the current graph is used.

  • bind_position (bool) – Whether to call bind(point_x=, point_y=) (default True)

  • x_out_col (str) – Attribute to write x position to. (default ‘x’)

  • y_out_col (str) – Attribute to write x position to. (default ‘y’)

  • play (Optional[str]) – If defined, set settings(url_params={‘play’: play}). (default 0)

Returns

Plotter

Return type

Plotter

Example: ForceAtlas2 layout
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g.layout_cugraph().plot()
Example: Change which column names are generated
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.layout_cugraph('force_atlas2', x_out_col='my_x', y_out_col='my_y')
assert 'my_x' in g2._nodes
assert g2._point_x == 'my_x'
g2.plot()
Example: Pass parameters to layout methods
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.layout_cugraph('forceatlas_2', params={'lin_log_mode': True, 'prevent_overlapping': True})
g2.plot()
layout_igraph(layout, directed=None, use_vids=False, bind_position=True, x_out_col='x', y_out_col='y', play=0, params={})

Compute graph layout using igraph algorithm. For a list of layouts, see layout_algs or igraph documentation.

Parameters
  • layout (str) – Name of an igraph.Graph.layout method like sugiyama

  • directed (Optional[bool]) – During the to_igraph conversion, whether to be directed. If None, try directed and then undirected. (default None)

  • use_vids (bool) – Whether to use igraph vertex ids (non-negative integers) or arbitary node ids (False, default)

  • bind_position (bool) – Whether to call bind(point_x=, point_y=) (default True)

  • x_out_col (str) – Attribute to write x position to. (default ‘x’)

  • y_out_col (str) – Attribute to write x position to. (default ‘y’)

  • play (Optional[str]) – If defined, set settings(url_params={‘play’: play}). (default 0)

  • params (dict) – Any named parameters to pass to the underlying igraph method

Returns

Plotter

Return type

Plotter

Example: Sugiyama layout
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.layout_igraph('sugiyama')
assert 'x' in g2._nodes
g2.plot()
Example: Change which column names are generated
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.layout_igraph('sugiyama', x_out_col='my_x', y_out_col='my_y')
assert 'my_x' in g2._nodes
assert g2._point_x == 'my_x'
g2.plot()
Example: Pass parameters to layout methods - Sort nodes by degree
import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g2 = g.get_degrees()
assert 'degree' in g._nodes.columns
g3 = g.layout_igraph('sugiyama', params={'layers': 'degree'})
g3.plot()
layout_settings(play=None, locked_x=None, locked_y=None, locked_r=None, left=None, top=None, right=None, bottom=None, lin_log=None, strong_gravity=None, dissuade_hubs=None, edge_influence=None, precision_vs_speed=None, gravity=None, scaling_ratio=None)

Set layout options. Additive over previous settings.

Corresponds to options at https://hub.graphistry.com/docs/api/1/rest/url/#urloptions

Example: Animated radial layout

import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'boss': ['c','c','e','e']})
nodes = pd.DataFrame({
    'n': ['a', 'b', 'c', 'd', 'e'],
    'y': [1,   1,   2,   3,   4],
    'x': [1,   1,   0,   0,   0],
})
g = (graphistry
    .edges(edges, 's', 'd')
    .nodes(nodes, 'n')
    .layout_settings(locked_r=True, play=2000)
g.plot()
Parameters
  • play (Optional[int]) –

  • locked_x (Optional[bool]) –

  • locked_y (Optional[bool]) –

  • locked_r (Optional[bool]) –

  • left (Optional[float]) –

  • top (Optional[float]) –

  • right (Optional[float]) –

  • bottom (Optional[float]) –

  • lin_log (Optional[bool]) –

  • strong_gravity (Optional[bool]) –

  • dissuade_hubs (Optional[bool]) –

  • edge_influence (Optional[float]) –

  • precision_vs_speed (Optional[float]) –

  • gravity (Optional[float]) –

  • scaling_ratio (Optional[float]) –

name(name)

Upload name

Parameters

name (str) – Upload name

networkx2pandas(g)
networkx_checkoverlap(g)
nodes(nodes, node=None, *args, **kwargs)

Specify the set of nodes and associated data. If a callable, will be called with current Plotter and whatever positional+named arguments

Must include any nodes referenced in the edge list.

Parameters

nodes (Pandas dataframe or Callable) – Nodes and their attributes.

Returns

Plotter

Return type

Plotter

Example
import graphistry

es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
g = graphistry
    .bind(source='src', destination='dst')
    .edges(es)

vs = pandas.DataFrame({'v': [0,1,2], 'lbl': ['a', 'b', 'c']})
g = g.bind(node='v').nodes(vs)

g.plot()
Example
import graphistry

es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
g = graphistry.edges(es, 'src', 'dst')

vs = pandas.DataFrame({'v': [0,1,2], 'lbl': ['a', 'b', 'c']})
g = g.nodes(vs, 'v)

g.plot()
Example
import graphistry

def sample_nodes(g, n):
    return g._nodes.sample(n)

df = pandas.DataFrame({'id': [0,1,2], 'v': [1,2,0]})

graphistry
    .nodes(df, 'id')
    ..nodes(sample_nodes, n=2)
    ..nodes(sample_nodes, None, 2)  # equivalent
    .plot()
nodexl(xls_or_url, source='default', engine=None, verbose=False)
pandas2igraph(edges, directed=True)

Convert a pandas edge dataframe to an IGraph graph.

Uses current bindings. Defaults to treating edges as directed.

Example
import graphistry
g = graphistry.bind()

es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
g = g.bind(source='src', destination='dst')

ig = g.pandas2igraph(es)
ig.vs['community'] = ig.community_infomap().membership
g.bind(point_color='community').plot(ig)
pipe(graph_transform, *args, **kwargs)

Create new Plotter derived from current

Parameters

graph_transform (Callable) –

Example: Simple
import graphistry

def fill_missing_bindings(g, source='src', destination='dst):
    return g.bind(source=source, destination=destination)

graphistry
    .edges(pandas.DataFrame({'src': [0,1,2], 'd': [1,2,0]}))
    .pipe(fill_missing_bindings, destination='d')  # binds 'src'
    .plot()
Return type

Plottable

plot(graph=None, nodes=None, name=None, description=None, render=None, skip_upload=False, as_files=False, memoize=True, extra_html='', override_html_style=None, validate=True)

Upload data to the Graphistry server and show as an iframe of it.

Uses the currently bound schema structure and visual encodings. Optional parameters override the current bindings.

When used in a notebook environment, will also show an iframe of the visualization.

Parameters
  • graph (Any) – Edge table (pandas, arrow, cudf) or graph (NetworkX, IGraph).

  • nodes (Any) – Nodes table (pandas, arrow, cudf)

  • name (str) – Upload name.

  • description (str) – Upload description.

  • render (bool) – Whether to render the visualization using the native notebook environment (default True), or return the visualization URL

  • skip_upload (bool) – Return node/edge/bindings that would have been uploaded. By default, upload happens.

  • as_files (bool) – Upload distinct node/edge files under the managed Files PI. Default off, will switch to default-on when stable.

  • memoize (bool) – Tries to memoize pandas/cudf->arrow conversion, including skipping upload. Default on.

  • extra_html (Optional[str]) – Allow injecting arbitrary HTML into the visualization iframe.

  • override_html_style (Optional[str]) – Set fully custom style tag.

  • validate (Optional[bool]) – Controls validations, including those for encodings.

Example: Simple
import graphistry
es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
graphistry
    .bind(source='src', destination='dst')
    .edges(es)
    .plot()
Example: Shorthand
import graphistry
es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
graphistry
    .bind(source='src', destination='dst')
    .plot(es)
privacy(mode=None, notify=None, invited_users=None, message=None)

Set local sharing mode

Parameters
  • mode (Optional[Mode]) – Either “private”, “public”, or inherit from global privacy()

  • notify (Optional[bool]) – Whether to email the recipient(s) upon upload, defaults to global privacy()

  • invited_users (Optional[List]) – List of recipients, where each is {“email”: str, “action”: str} and action is “10” (view) or “20” (edit), defaults to global privacy()

  • message (Optional[str]) – Email to send when notify=True

Requires an account with sharing capabilities.

Shared datasets will appear in recipients’ galleries.

If mode is set to “private”, only accounts in invited_users list can access. Mode “public” permits viewing by any user with the URL.

Action “10” (view) gives read access, while action “20” (edit) gives edit access, like changing the sharing mode.

When notify is true, uploads will trigger notification emails to invitees. Email will use visualization’s “.name()”

When settings are not specified, they are inherited from the global graphistry.privacy() defaults

Example: Limit visualizations to current user

import graphistry
graphistry.register(api=3, username='myuser', password='mypassword')

#Subsequent uploads default to using .privacy() settings
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True)
g = h['graph']
g = g.privacy()  # default uploads to mode="private"
g.plot()

Example: Default to publicly viewable visualizations

import graphistry
graphistry.register(api=3, username='myuser', password='mypassword')

#Subsequent uploads default to using .privacy() settings
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True)
g = h['graph']
#g = g.privacy(mode="public")  # can skip calling .privacy() for this default
g.plot()

Example: Default to sharing with select teammates, and keep notifications opt-in

import graphistry
graphistry.register(api=3, username='myuser', password='mypassword')

#Subsequent uploads default to using .privacy() settings
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True)
g = h['graph']
g = g.privacy(
    mode="private",
    invited_users=[
        {"email": "friend1@acme.org", "action": "10"}, # view
        {"email": "friend2@acme.org", "action": "20"}, # edit
    ],
    notify=False)
g.plot()

Example: Keep visualizations public and email notifications upon upload

import graphistry
graphistry.register(api=3, username='myuser', password='mypassword')

#Subsequent uploads default to using .privacy() settings
users_df = pd.DataFrame({'user': ['a','b','x'], 'boss': ['x', 'x', 'y']})
h = graphistry.hypergraph(users_df, direct=True)
g = h['graph']
g = g.name('my cool viz')  # For friendlier invitations
g = g.privacy(
    mode="public",
    invited_users=[
        {"email": "friend1@acme.org", "action": "10"}, # view
        {"email": "friend2@acme.org", "action": "20"}, # edit
    ],
    notify=True)
g.plot()
reset_caches()

Reset memoization caches

scene_settings(menu=None, info=None, show_arrows=None, point_size=None, edge_curvature=None, edge_opacity=None, point_opacity=None)

Set scene options. Additive over previous settings.

Corresponds to options at https://hub.graphistry.com/docs/api/1/rest/url/#urloptions

Example: Hide arrows and straighten edges

import graphistry, pandas as pd
edges = pd.DataFrame({'s': ['a','b','c','d'], 'boss': ['c','c','e','e']})
nodes = pd.DataFrame({
    'n': ['a', 'b', 'c', 'd', 'e'],
    'y': [1,   1,   2,   3,   4],
    'x': [1,   1,   0,   0,   0],
})
g = (graphistry
    .edges(edges, 's', 'd')
    .nodes(nodes, 'n')
    .scene_settings(show_arrows=False, edge_curvature=0.0)
g.plot()
Parameters
  • menu (Optional[bool]) –

  • info (Optional[bool]) –

  • show_arrows (Optional[bool]) –

  • point_size (Optional[float]) –

  • edge_curvature (Optional[float]) –

  • edge_opacity (Optional[float]) –

  • point_opacity (Optional[float]) –

settings(height=None, url_params={}, render=None)

Specify iframe height and add URL parameter dictionary.

The library takes care of URI component encoding for the dictionary.

Parameters
  • height (int) – Height in pixels.

  • url_params (dict) – Dictionary of querystring parameters to append to the URL.

  • render (bool) – Whether to render the visualization using the native notebook environment (default True), or return the visualization URL

style(fg=None, bg=None, page=None, logo=None)

Set general visual styles

See .bind() and .settings(url_params={}) for additional styling options, and addStyle() for another way to set the same attributes.

To facilitate reuse and replayable notebooks, the style() call is chainable. Invocation does not effect the old style: it instead returns a new Plotter instance with the new styles added to the existing ones. Both the old and new styles can then be used for different graphs.

style() will fully replace any defined parameter in the existing style settings, while addStyle() will merge over previous values

Parameters
  • fg (dict) – Dictionary {‘blendMode’: str} of any valid CSS blend mode

  • bg (dict) – Nested dictionary of page background properties. { ‘color’: str, ‘gradient’: {‘kind’: str, ‘position’: str, ‘stops’: list }, ‘image’: { ‘url’: str, ‘width’: int, ‘height’: int, ‘blendMode’: str }

  • logo (dict) – Nested dictionary of logo properties. { ‘url’: str, ‘autoInvert’: bool, ‘position’: str, ‘dimensions’: { ‘maxWidth’: int, ‘maxHeight’: int }, ‘crop’: { ‘top’: int, ‘left’: int, ‘bottom’: int, ‘right’: int }, ‘padding’: { ‘top’: int, ‘left’: int, ‘bottom’: int, ‘right’: int}, ‘style’: str}

  • page (dict) – Dictionary of page metadata settings. { ‘favicon’: str, ‘title’: str }

Returns

Plotter

Return type

Plotter

Example: Chained merge - results in url and blendMode being set, while color is dropped
g2 =  g.style(bg={'color': 'black'}, fg={'blendMode': 'screen'})
g3 = g2.style(bg={'image': {'url': 'http://site.com/watermark.png'}})
Example: Gradient background
g.style(bg={'gradient': {'kind': 'linear', 'position': 45, 'stops': [['rgb(0,0,0)', '0%'], ['rgb(255,255,255)', '100%']]}})
Example: Page settings
g.style(page={'title': 'Site - {{ name }}', 'favicon': 'http://site.com/logo.ico'})
tigergraph(protocol='http', server='localhost', web_port=14240, api_port=9000, db=None, user='tigergraph', pwd='tigergraph', verbose=False)

Register Tigergraph connection setting defaults

Parameters
  • protocol (Optional[str]) – Protocol used to contact the database.

  • server (Optional[str]) – Domain of the database

  • web_port (Optional[int]) –

  • api_port (Optional[int]) –

  • db (Optional[str]) – Name of the database

  • user (Optional[str]) –

  • pwd (Optional[str]) –

  • verbose (Optional[bool]) – Whether to print operations

Returns

Plotter

Return type

Plotter

Example: Standard
import graphistry
tg = graphistry.tigergraph(protocol='https', server='acme.com', db='my_db', user='alice', pwd='tigergraph2')                    
to_cugraph(directed=True, include_nodes=True, node_attributes=None, edge_attributes=None, kind='Graph')

Convert current graph to a cugraph.Graph object

To assign an edge weight, use g.bind(edge_weight=’some_col’).to_cugraph()

Load from pandas, cudf, or dask_cudf DataFrames

Parameters
  • directed (bool) –

  • include_nodes (bool) –

  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

  • kind (Literal[‘Graph’, ‘MultiGraph’, ‘BiPartiteGraph’]) –

to_igraph(directed=True, use_vids=False, include_nodes=True, node_attributes=None, edge_attributes=None)

Convert current item to igraph Graph . See examples in from_igraph.

Parameters
  • directed (bool) – Whether to create a directed graph (default True)

  • include_nodes (bool) – Whether to ingest the nodes table, if it exists (default True)

  • node_attributes (Optional[List[str]]) – Which node attributes to load, None means all (default None)

  • edge_attributes (Optional[List[str]]) – Which edge attributes to load, None means all (default None)

  • use_vids (bool) – Whether to interpret IDs as igraph vertex IDs, which must be non-negative integers (default False)

graphistry.PlotterBase.maybe_cudf()
graphistry.PlotterBase.maybe_dask_cudf()
graphistry.PlotterBase.maybe_dask_dataframe()
graphistry.PlotterBase.maybe_spark()

Plotter Modules

class graphistry.Plottable.Plottable(*args, **kwargs)

Bases: object

DGL_graph: Optional[Any]
bind(source=None, destination=None, node=None, edge=None, edge_title=None, edge_label=None, edge_color=None, edge_weight=None, edge_size=None, edge_opacity=None, edge_icon=None, edge_source_color=None, edge_destination_color=None, point_title=None, point_label=None, point_color=None, point_weight=None, point_size=None, point_opacity=None, point_icon=None, point_x=None, point_y=None)
chain(ops)

ops is List[ASTObject]

Parameters

ops (List[Any]) –

Return type

Plottable

collapse(node, attribute, column, self_edges=False, unwrap=False, verbose=False)
Parameters
  • node (Union[str, int]) –

  • attribute (Union[str, int]) –

  • column (Union[str, int]) –

  • self_edges (bool) –

  • unwrap (bool) –

  • verbose (bool) –

Return type

Plottable

compute_cugraph(alg, out_col=None, params={}, kind='Graph', directed=True, G=None)
Parameters
  • alg (str) –

  • out_col (Optional[str]) –

  • params (dict) –

  • kind (Literal[‘Graph’, ‘MultiGraph’, ‘BiPartiteGraph’]) –

  • G (Optional[Any]) –

copy()
drop_nodes(nodes)
Parameters

nodes (Any) –

Return type

Plottable

edges(edges, source=None, destination=None, edge=None, *args, **kwargs)
Parameters
  • edges (Union[Callable, Any]) –

  • source (Optional[str]) –

  • destination (Optional[str]) –

  • edge (Optional[str]) –

Return type

Plottable

filter_edges_by_dict(filter_dict=None)
Parameters

filter_dict (Optional[dict]) –

Return type

Plottable

filter_nodes_by_dict(filter_dict=None)
Parameters

filter_dict (Optional[dict]) –

Return type

Plottable

from_cugraph(G, node_attributes=None, edge_attributes=None, load_nodes=True, load_edges=True, merge_if_existing=True)
Parameters
  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

  • load_nodes (bool) –

  • load_edges (bool) –

  • merge_if_existing (bool) –

from_igraph(ig, node_attributes=None, edge_attributes=None, load_nodes=True, load_edges=True, merge_if_existing=True)
Parameters
  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

  • load_nodes (bool) –

  • load_edges (bool) –

  • merge_if_existing (bool) –

get_degrees(col='degree', degree_in='degree_in', degree_out='degree_out')
Parameters
  • col (str) –

  • degree_in (str) –

  • degree_out (str) –

Return type

Plottable

get_indegrees(col='degree_in')
Parameters

col (str) –

Return type

Plottable

get_outdegrees(col='degree_out')
Parameters

col (str) –

Return type

Plottable

get_topological_levels(level_col='level', allow_cycles=True, warn_cycles=True, remove_self_loops=True)
Parameters
  • level_col (str) –

  • allow_cycles (bool) –

  • warn_cycles (bool) –

  • remove_self_loops (bool) –

Return type

Plottable

hop(nodes, hops=1, to_fixed_point=False, direction='forward', edge_match=None, source_node_match=None, destination_node_match=None, source_node_query=None, destination_node_query=None, edge_query=None, return_as_wave_front=False, target_wave_front=None)
Parameters
  • nodes (Optional[DataFrame]) –

  • hops (Optional[int]) –

  • to_fixed_point (bool) –

  • direction (str) –

  • edge_match (Optional[dict]) –

  • source_node_match (Optional[dict]) –

  • destination_node_match (Optional[dict]) –

  • source_node_query (Optional[str]) –

  • destination_node_query (Optional[str]) –

  • edge_query (Optional[str]) –

  • return_as_wave_front (bool) –

  • target_wave_front (Optional[DataFrame]) –

Return type

Plottable

keep_nodes(nodes)
Parameters

nodes (Union[List, Any]) –

Return type

Plottable

layout_cugraph(layout='force_atlas2', params={}, kind='Graph', directed=True, G=None, bind_position=True, x_out_col='x', y_out_col='y', play=0)
Parameters
  • layout (str) –

  • params (dict) –

  • kind (Literal[‘Graph’, ‘MultiGraph’, ‘BiPartiteGraph’]) –

  • G (Optional[Any]) –

  • bind_position (bool) –

  • x_out_col (str) –

  • y_out_col (str) –

  • play (Optional[int]) –

layout_settings(play=None, locked_x=None, locked_y=None, locked_r=None, left=None, top=None, right=None, bottom=None, lin_log=None, strong_gravity=None, dissuade_hubs=None, edge_influence=None, precision_vs_speed=None, gravity=None, scaling_ratio=None)
Parameters
  • play (Optional[int]) –

  • locked_x (Optional[bool]) –

  • locked_y (Optional[bool]) –

  • locked_r (Optional[bool]) –

  • left (Optional[float]) –

  • top (Optional[float]) –

  • right (Optional[float]) –

  • bottom (Optional[float]) –

  • lin_log (Optional[bool]) –

  • strong_gravity (Optional[bool]) –

  • dissuade_hubs (Optional[bool]) –

  • edge_influence (Optional[float]) –

  • precision_vs_speed (Optional[float]) –

  • gravity (Optional[float]) –

  • scaling_ratio (Optional[float]) –

materialize_nodes(reuse=True, engine=<EngineAbstract.AUTO: 'auto'>)
Parameters
  • reuse (bool) –

  • engine (Union[EngineAbstract, str]) –

Return type

Plottable

nodes(nodes, node=None, *args, **kwargs)
Parameters
  • nodes (Union[Callable, Any]) –

  • node (Optional[str]) –

Return type

Plottable

pipe(graph_transform, *args, **kwargs)
Parameters

graph_transform (Callable) –

Return type

Plottable

prune_self_edges()
Return type

Plottable

to_cugraph(directed=True, include_nodes=True, node_attributes=None, edge_attributes=None, kind='Graph')
Parameters
  • directed (bool) –

  • include_nodes (bool) –

  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

  • kind (Literal[‘Graph’, ‘MultiGraph’, ‘BiPartiteGraph’]) –

Return type

Any

to_igraph(directed=True, use_vids=False, include_nodes=True, node_attributes=None, edge_attributes=None)
Parameters
  • directed (bool) –

  • use_vids (bool) –

  • include_nodes (bool) –

  • node_attributes (Optional[List[str]]) –

  • edge_attributes (Optional[List[str]]) –

Return type

Any