Skip to content

Commit 6a382e9

Browse files
committed
Edges are no longer repeated in adjlists, and are made multigraph compatible.
1 parent f02dd5e commit 6a382e9

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graph-creator",
3-
"version": "0.8.3",
3+
"version": "0.9.0",
44
"main": "index.html",
55
"window": {
66
"height": 1024,

src/fileWrite.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ function makeAdjlist(nodeList){
4343

4444
//Go through each vertex and add it's edges to the adjlist
4545
for(var i = 0; i < nodeList.length; i++){
46-
var edges = nodeList[i].connectedEdges();
46+
47+
//Get all the edges that have a target from our current node
48+
var edges = nodeList[i].edgesTo(nodeList);
4749
var numEdges = edges.length;
4850

4951
//Check if the user has made a label
@@ -59,27 +61,15 @@ function makeAdjlist(nodeList){
5961
for(var k=0; k<numEdges; k++){
6062

6163

62-
//Check if the target is the node itself and use the source instead
63-
if(edges[k].data('target') === nodeList[i].data('id')){
64-
var targetLabel = cy.getElementById(edges[k].data('source')).style('label');
64+
var targetLabel = cy.getElementById(edges[k].data('target')).style('label');
6565

66-
if(targetLabel !== ''){
67-
adjlist = adjlist + targetLabel;
68-
}
69-
else{
70-
adjlist = adjlist + edges[k].data('source');
71-
}
66+
if(targetLabel !== ''){
67+
adjlist = adjlist + targetLabel;
7268
}
7369
else{
74-
var targetLabel = cy.getElementById(edges[k].data('target')).style('label');
75-
76-
if(targetLabel !== ''){
77-
adjlist = adjlist + targetLabel;
78-
}
79-
else{
80-
adjlist = adjlist + edges[k].data('target');
81-
}
70+
adjlist = adjlist + edges[k].data('target');
8271
}
72+
8373

8474
//If we are weighted get a weight and write it
8575
if(weighted){

0 commit comments

Comments
 (0)