Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to render self-loops? #1429

Open
Bufoh opened this issue May 24, 2024 · 0 comments
Open

How to render self-loops? #1429

Bufoh opened this issue May 24, 2024 · 0 comments

Comments

@Bufoh
Copy link

Bufoh commented May 24, 2024

Hi everyone, this library is really amazing and I have been using it a lot lately for a scientific project. My problem is that I could not get self-loops (self-interactions) to render. I have created a minimal version of my code below. Am I missing something?

The libraries I use are:

├── @sigma/edge-curve@3.0.0-beta.7
├── graphology@0.25.4
├── sigma@3.0.0-beta.18
└── vite@5.2.11

And my javascript is:

import Graph from "graphology";
import Sigma from "sigma";
import EdgeCurveProgram, { DEFAULT_EDGE_CURVATURE } from "@sigma/edge-curve";

// Create a graph instance
const graph = new Graph({
  'allowSelfLoops': true,
  'type': 'undirected',
});

// Add test nodes and edges
graph.addNode('n1', {x: 5, y: 5, size: 20});
graph.addNode('n2', {x: 10, y: 5, size: 20});
graph.addNode('n3', {x: 7.5, y: 4, size: 20});
graph.addEdge('n1', 'n2', {size: 10, type: 'line'});
graph.addEdge('n1', 'n3', {size: 10, type: 'curved'});
// Played around with curvature value, but this does not seem to be the issue
graph.addEdge('n2', 'n2', {size: 10, type: 'curved', curvature: DEFAULT_EDGE_CURVATURE});

// this is a simple div
const container = document.getElementById("sigma-container");

// Instantiate sigma.js and render the graph
const sigmaInstance = new Sigma(graph, container, {
  edgeProgramClasses: {
    curved: EdgeCurveProgram
  }
});

sigmaInstance.refresh();

which for me results in:
Screenshot 2024-05-24 at 15 32 18

but I would like to achieve:
Screenshot 2024-05-24 at 15 32 18

Any help would be highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants