-
-
Save jacomyal/2209633 to your computer and use it in GitHub Desktop.
/* | |
Add the function to the public prototype : | |
*/ | |
sigma.publicPrototype.outDegreeToSize = function() { | |
this.iterNodes(function(node){ | |
node.size = node.outDegree; | |
}).draw(); | |
}; | |
/* | |
Of course, it works as well with node.degree and node.inDegree. | |
How to test it: | |
1. Open any sigma example - http://sigmajs.org/examples.html | |
2. Open a console - http://bit.ly/GVshi6 | |
3. Enter the previous code | |
4. Try it on the first sigma.js instance on the page: | |
sigma.instances[1].outDegreeToSize(); | |
Also, if you want to choose the minimum/maximum node sizes: | |
sigma.instances[1].graphProperties({ | |
minNodeSize: 1, | |
maxNodeSize: 3 | |
}); | |
*/ |
Thanks a lot again for your help!
I download the library again, changed back the code to use node.outDegree but in the Chrome debugger I got the "undefined" error, and as you can see for yourself here, http://dl.dropbox.com/u/6326953/NoOutDegree.JPG , there's no attribute named like outDegree or inDegree in the node object.
About the edge direction issue, I expected to see a sort of directed arrow instead of just a "link" between the source and the target.
Here is what I see: http://dl.dropbox.com/u/6326953/Edges.JPG
Thanks!
Valerio
About the issue with outDegree
and inDegree
, I will take a look as soon as I can - i will let you know when I solve the problem.
About the edge direction issue:
To have the edges drawn as curves, you can either add a type
attribute to your directed edges when you create them, like:
sigma.instances[1].addEdge('hello_world','hello','world',{
type: 'curve'
});
Or you can set the defaultEdgeType
to curve
(by default, it's line
):
sigma.instances[1].drawingProperties({
defaultEdgeType: 'curve'
});
Currenlty line
and curve
are the only types implemented, but it is possible to add some more later (like arrow
, for instance).
Ok thanks a lot for all the effort in supporting me, it is really appreciated!
I changed the defaultEdgeType to curve, though I think that the attribute's name is a bit misleading as in the GEXF schema, that name is used to say if the edge is directed
, undirected
or mutual
.
Thanks,
Valerio
Also I found a very small mistake in the sigma.parseGexf.js library to parse the gexf file:
at line 138 you have: var al = attvalueNode.getAttribute('value');
and then the next line is edge.attributes.push({attr:attr, val:val});
But variable val
doesn't exist as the defined variable name is al
by mistake.
Valerio
First, about the edges and the GEXF schema, I get your point, but sigma.js is initially only a graph drawing engine - which is why even the ForceAtlas2 is implemented as a plugin. So, I prefer the type of an edge to be describing its appearance, then it is easier to customize how to draw them (like arrow
, curve2
, dotted
, etc...).
About the mistake in the GEXF parser, thanks a lot, I am fixing it, it will be updated in the repository soon :)
I see and understand your point.
Anyway the library is working perfectly now about inDegree
and outDegree
attributes, thanks a lot for all the time you spent dealing with me!
Valerio
Hi,
can we get pagerank, Closeness Centrality, Eigenvector Centrality of nodes ?
Thanks
I'd also be interested in hgillh request
Hi,
sigma.publicPrototype.outDegreeToSize = function() {
this.iterNodes(function(node){
node.size = node.outDegree;
}).draw();
};
/*
Of course, it works as well with node.degree and node.inDegree.
How to test it:
- Open any sigma example - http://sigmajs.org/examples.html
- Open a console - http://bit.ly/GVshi6
- Enter the previous code
- Try it on the first sigma.js instance on the page:
sigma.instances[1].outDegreeToSize();
Also, if you want to choose the minimum/maximum node sizes:
sigma.instances[1].graphProperties({
minNodeSize: 1,
maxNodeSize: 3
});
I need working example for ""outDegreeToSize"" plz help me every thing else is working fine with Sigma.js plz give me the even the shortest example but give me the one which is working i will modify it accordingly... waiting for reply..
By example i mean like other example on sigma.js they are so helpfull put this code in one of this example and post it here .. thats all i want... Thanx in advance...
Did this change with v1.0.0? I am opening examples/basic.html but I am getting one error. I will post what I do.
First, I am trying sigma.instances()
, but this method is not working without id:
TypeError: Object #<Object> has no method 'extends'
This is throwing an error:"sigma.publicPrototype is undefined".What to do?
Thank you very much for your help!
The only problem I'm having with your code is that node.outDegree is undefined!
I'm using node.degree at the moment, and I'm trying to change the color of the node based on the degree as well, so that important nodes can be immediately spotted in the graph by the user.
I will do the same for the edges.
Would be good if you could release an updated version of the library that is defining inDegree and outDegree for each node.
I'm also having problem displaying directions for edges, even though all my edges are directed and I correctly specified source and target.
Do you have any clue about this?
Here is my stripped down graph (I replaced "<" with "(" ):
(graph mode="static" defaultedgetype="directed")
(nodes)
(node id="i260" label="Johnson Stephen"/)
(node id="1003234" label="Gujral Dorothy"/)
....
(/nodes)
(edges)
(edge id="2" source="i260" target="1003234" /)
(/edges)
(/graph)