Currently the virtual nodes are connected to all real nodes in graph construction if any. You can develop your own graph construction function from that. For example, let’s say we want to construct a molecular graph where each ring is connected to a virtual node then the following code is what you need
from dgllife.utils import mol_to_bigraph
from rdkit import Chem
# Use the SMILES string of Penicillin as an example
smi = 'CC1([C@@H](N2[C@H](S1)[C@@H](C2=O)NC(=O)Cc3ccccc3)C(=O)O)C'
mol = Chem.MolFromSmiles(smi)
g = mol_to_bigraph(mol)
sssr = Chem.GetSymmSSSR(mol)
num_nodes = g.num_nodes()
src = []
dst = []
for ring in sssr:
ring = list(ring)
# Add edges for both directions
src.extend([num_nodes] * len(ring))
dst.extend(ring)
src.extend(ring)
dst.extend([num_nodes] * len(ring))
num_nodes += 1
g.add_edges(src, dst)