From the ipycytoscape documentation I can see the following:
import ipycytoscape as cs
from ipycytoscape import *
import networkx as nx
# === create custom node class (inherits from cytoscape node class)
class CustomNode(cs.Node):
def __init__(self, name, classes=''):
super().__init__()
self.data['id'] = name
self.classes = classes
n1 = CustomNode("node 1", classes='class1')
n2 = CustomNode("node 2", classes='class2')
# === create graph, add custom nodes and an edge
G = nx.Graph()
G.add_node(n1)
G.add_node(n2)
G.add_edge(n1, n2, directed=True)
My question is a fundamental one, rather than looking for helping with code. Above n1 and n2 are built with a class inheriting from a ipycytoscape class CustomNode(cs.Node). But they are added as nodes to a networkx graph !!!
How is that possible? What I mean is that a ipycytoscape object is added to a networkx object.