The CytoscapeWidget accepts an optional graph parameter, using this we can pass the graph's data and initialise a graph. We can pass data as:
import ipycytoscape
# 1. a cytoscape graph from json file
json_from_filename = ipycytoscape.CytoscapeWidget("concentricData.json")
json_from_filename
CytoscapeWidget(cytoscape_layout={'name': 'cola'}, cytoscape_style=[{'selector': 'node', 'css': {'background-c…
# 1. a cytoscape graph from json object
import json
with open("concentricData.json") as fi:
json_file = json.load(fi)
json_from_object = ipycytoscape.CytoscapeWidget(json_file)
json_from_object
CytoscapeWidget(cytoscape_layout={'name': 'cola'}, cytoscape_style=[{'selector': 'node', 'css': {'background-c…
# A networkx graph
import networkx as nx
G = nx.complete_graph(5)
graph_from_nx = ipycytoscape.CytoscapeWidget(G)
graph_from_nx
CytoscapeWidget(cytoscape_layout={'name': 'cola'}, cytoscape_style=[{'selector': 'node', 'css': {'background-c…
# A pandas Dataframe
import pandas as pd
graphFrame = pd.read_csv("https://raw.githubusercontent.com/nextstrain/ncov/fe5a7ed1f92af63d6d1d43d0307e4b2620108aaa/data/metadata.tsv", sep = '\t')
ipycytoscape.CytoscapeWidget(graphFrame[:30], groupby_cols=['country'], attribute_list=['age', 'virus'])
CytoscapeWidget(cytoscape_layout={'name': 'cola'}, cytoscape_style=[{'selector': 'node', 'css': {'background-c…
# NBVAL_SKIP
# A neo4j graph
from py2neo import Graph, Node, Relationship
g = graph = Graph("bolt://132.249.238.185:7687", user="reader", password="demo")
ipycytoscape.CytoscapeWidget(g)
# A ipycytoscape graph
ipycytoscape.CytoscapeWidget(json_from_object.graph)