fkling / jsnetworkx Goto Github PK
View Code? Open in Web Editor NEWBuild, process and analyze graphs in JavaScript (port of NetworkX)
Home Page: https://felix-kling.de/jsnetworkx/
License: Other
Build, process and analyze graphs in JavaScript (port of NetworkX)
Home Page: https://felix-kling.de/jsnetworkx/
License: Other
This might make maintaining the visualization part easier and encourages more contribution to it.
Since this is one of the main difference with the Python library, I thought I'd start an issue.
How to generate a graphviz dot file from a NetworkX graph?
Should we stick with underscores, ie.add_nodes_from
, to be closer to the Python implementation, or use the more common camelCase notation (addNodesFrom
)?
I intend to start publishing pre-release versions to NPM as soon as the API documentation generation system is in place, and the change to camelCase API is complete.
Hey, great job on making this library! Wanted to point out a very minor typo on "Getting Started" section. This line below is missing a " mark. http://felix-kling.de/JSNetworkX/getting_started.html
<script src="jsnetworkx.js></script>
Hello,
I've used the python version of Networkx so was interested in trying out this port.
I'm working on Windows 7 box and use the RubyMine IDE I've created a script tag
<script src="js/jsnetworkx.js"></script> <script src="js/main.js"></script>However in my main.js if I declare
var G = jsnx.complete_graph(6);
The error jsnx unresolved is produced, can you advise what I'm doing wrong?
Brian
Is there an obvious way of visualising a network created using JSNetworkX that has x,y, node size, node colour attributes already associated with nodes?
JSNetworkX makes use of Google closures iterator module, which recognises objects with a __iterator__
a iterables.
Firefox' JavaScript version also supports this property, but for normal for...in
loops, and thus, every for...in
statement that is supposed to iterate over the properties of such an object breaks.
Hello there,
wondering if you need a mantainer to update some part of the codebase and be inline with the PRs,
ping me in case!
n
Hi, I've run into some trouble lately since I had to modify JSNetworkX. Recompiling with the latest version of the Closure Library (or maybe it's the newer Closure Compiler?) seems to cause .next()
to be obfuscated on all iterators. Graph.nodes_iter()
and jsnx.sentinelIterator()
both return fully obfuscated objects. I checked both on my changes and on 031524a, but got the same result (.next()
gets renamed to b
). Any suggestions?
Does JSNetworkX support any other shape than circle?
Hi ,I want to add a string on every node, but with_labels just add the node's name in the circle ,how to make a label beside the circle ? and I also want to set different size for every circle , thank you very much .
After looking at the codebase, I haven't found this because well, it's probably not something someone really should do, meaning that they should really port it to some other representation.
But it might help those moving from NetworkX to JSNetworkX to easily adopt. It also helps those who are more dependent on Gephi for network science. This also could mean that JSNetworkX could potentially build a browser based version of Gephi should this project grow that way.
I thought I'd just begin the discussion.
Self loops are not shown in the graph. Furthermore, if the graph is drawn with labels, self loop labels appear in the upper left corner of the canvas.
Now , when click one node , the scale of graphic changed too much ,is there a parameter to set? Thank you very much .
Running the tests in node should be sufficient most of the time, but being able to run them in the browser as well would be an additional safe guard.
Hi,
Unfortunately, I think that a recent change in D3 (see d3/d3#2411) has broken the rendering procedure of JSNetworkX. Specifically, in:
https://github.com/fkling/JSNetworkX/blob/master/src/drawing/svg.js#L375
d3.event.sourceEvent
should be probably tested against null
. If I got it right, sourceEvent
has even been removed from newer versions of D3. For now, I'm preventing the dblclick.zoom
event by doing:
d3.select('svg.jsnx').on('dblclick.zoom', null);
Thanks.
NetworkX 1.9 also has additional unit tests.
I have a JavaScript version of the max_weighted_matching
procedure here. It is not a port of the NetworkX version but of the original implementation made by Joris van Rantwijk. I do not know if this can help.
Hi,
I am trying to use jsnx for a project. I am successfully able to maintain and update the graph data structure and use the ported functions to get the values I need. However, when trying to compute the eigenvectorCentrality, I get the following error:
"Uncaught #" (jsnetworkx.js - Line 2)
I can't figure what the issue is since other functions seem to be working just fine with the same graph. This is the syntax I am using
jsnx.eigenvectorCentrality(networkXGraph)
where networkXGraph holds the graph I am using.
Any help with this would be greatly appreciated.
At least make sure that the methods exist (transpilation works) and they run without errors (promises get resolved).
Hey There, I am happy to help start knocking out some of the basic centrality algos.
I have a small contribution in the python library.
Nice work on the library - really love the implementation of ES6! JavaScript is really making it easier to do this kind of work.
I've noticed that subclasses of Graph pretty much completely re-implement the Graph api, rather than delegating to internal methods and just overriding those internal methods.
Is there a reason for this? Performance?
I'm going to use this new issue as a way to document my progress of refactoring the code. I'm also happy to receive comments and suggestions.
(this is an experiment, I'm not sure if I'm disciplined enough to keep this up, but I will try my best :) )
Passing true
as third parameter to jsnx.draw
does not seem to have any effect. I can see the graph wobble a bit, but new nodes/edges are not visible.
I have JSON prepared from the Python version of networkx, and it's unclear if I can create a jsnetworkx object from this JSON data at https://github.com/fkling/JSNetworkX/blob/master/jsnx/classes/graph.js#L45.
Is this possible?
I want to display something when click a node , is there a way to do that? Thank you very much .
I mean that I want to place a image for the node instead of node_shape.
We cannot do CPU intensive computations without asynchronous processing (e.g. web workers). Should we change the API and always return promises from all algorithm functions, or provide an extra build which does that?
How easy would it be to integrate support for the sigmajs visualisation library?
I think the json graph representation that sigma.js accepts matches the one use by the d3.js network layout?
Currently the helper functions to iterate over "collections" iterate over the property names of an object, not its values. That's how it is in Python as well. I'm wondering if this is expected behavior or surprising. We could also iterate over the property values instead.
Maybe we should even distinguish between iterables with key => value
and index => value
, i.e. KeyedIterable
and IndexIterable
.
Doing this for the browser is pretty simply: We just have to enable the debug
option for browserify and produce inline source maps from the esnext transform step.
For Node, we have to produce inline source maps, and patch the stack trace generation to consider those maps. This can be done via https://github.com/evanw/node-source-map-support.
Current idea: Run a separate site/service that automatically rebuilds the documentation after pushing to GitHub.
The service will just be a React site that gets the API information from a JSON blob. The plan is to generate documentation for master and different versions (minor versions before 1.0). E.g. now we would only have master
. When v0.3
is released, we will have master
and the latest v0.3.x.
tag.
I will probably create a new repo for that.
Maybe I'm confused, but I was under the impression that the payload for nodes and edges was shallowly copied for the copy-constructor and deeply copied for the subgraph/to_directed/etc methods, but I see in test_0_graph.js
:
BaseAttrGraphTester.prototype.is_shallow_copy = function(H, G) {
this.graphs_equal(H, G);
this.different_attrdict(H, G);
this.shallow_copy_attrdict(H, G);
};
What am I missing?
There currently is only the draw
function which is like a one-of black box. It's not possible to make changes to the drawing config (without completely redrawing the graph), to extend it to support different kinds of visualization or different layouts.
I already started working on rewriting this part a long time ago and think that it's a good opportunity to introduce it with the next release.
The drawing API will be evolve around an abstract Visualization
class which exposes an API that allows easily update an existing visualization. This class can be subclassed to provide different implements. I already have one for SVG output (with D3) and WebGL (experimental, with Three.js). The configuration options will mostly stay the same, but the API is richer.
Usage will look something like this:
var v = jsnx.draw(G, container, {/* some config here */}); // defaults to SVG visualization
// now or later
v.labels(true); // show labels
// or
v.labels(function(d) { return d.data.name; }); // show labels and use node data "name"
v.nodeStyle({style: {fill: 'red' }}); // style options depend on visualization
An implementation might not support every method. E.g. the WebGL implementation currently doesn't support labels, so calling v.labels()
will just do nothing. On the other hand, implementations might offer additional methods, e.g. the WebGL implementation provides v.camera
to the set the camera to be used.
The following code will work when nodes are primitive objects, but not when complex objects.
function test(p) {
var G = new jsnx.Graph();
G.addStar(p, {weight: 1.0});
return jsnx.allPairsDijkstraPath(G)
}
test([1,2,3,4]); // works
test([{name: "cat"},{name: "dog"},{name: "mouse"}]); // fails
test([[0,0],[0,1],[1,0]]); // fails
The error message is
Uncaught TypeError: Cannot read property 'toString' of undefined(โฆ)
n @ jsnetworkx.js:1
d @ jsnetworkx.js:3
s @ jsnetworkx.js:3
b @ jsnetworkx.js:3
Note, that the code will work when allPairsDijkstraPath is replaced with allPairsShortestPath.
I have found and tried with shortest_path calculations for unweighted graph, but couldn't find similar functions for weighted graph. Can you help me with some explained examples if it is supported?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.