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 · 3 comments
Open

How to render self-loops? #1429

Bufoh opened this issue May 24, 2024 · 3 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/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]

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.

@Gvenvivar25
Copy link

Hi! Is there any news about self-loops? I also interested in this functionality.

@lukaszbachman
Copy link

Same here. I am about to choose a graph-rendering engine for my projects and without self-links I think I won't be able to rely on Sigma js. I did a bit of debugging and I see that links are generated with Graphology, but they are simply not rendered which brought me here. I would appreciate any information how to work around it, especially that as far as I have seen - it was working fine in previous versions of sigma.js.

@lukaszbachman
Copy link

BTW, in this comment someone posted an example implementation of this feature. Maybe something to be looked at as an inspiration?

@jacomyal jacomyal added this to the v3 milestone Sep 16, 2024
@jacomyal jacomyal removed this from the v3 milestone Sep 25, 2024
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

4 participants