benjoyo / forcedirectedplacement Goto Github PK
View Code? Open in Web Editor NEWJava implementation of Fruchterman and Reingold's graph layout algorithm using force-directed placement.
License: MIT License
Java implementation of Fruchterman and Reingold's graph layout algorithm using force-directed placement.
License: MIT License
It would be great if you could provide some examples for a simple graph which is layouted by the algorithm. I am trying to accomplish it with Processing, but I always get an RuntimeException: Edge factory failed
exception:
import org.jgrapht.*;
import org.jgrapht.graph.*;
import fdp.ForceDirectedPlacement;
import fdp.GraphConfiguration;
import fdp.Parameter;
import fdp.graph.Edge;
import fdp.graph.Vertex;
import fdp.graph.VertexFactory;
import javax.vecmath.Vector2d;
Graph<Vertex, Edge> graph = new SimpleGraph<Vertex, Edge>(Edge.class);
void setup() {
size(500, 500);
SimpleVertex v1 = new SimpleVertex("v1");
SimpleVertex v2 = new SimpleVertex("v2");
graph.addVertex(v1);
graph.addVertex(v2);
graph.addEdge(v1, v2);
// layout graph
Parameter p = new Parameter();
p.setFrameWidth(width);
p.setFrameHeight(height);
//p.setEquilibriumCriterion(mechEquiRadioButton.isSelected());
p.setAttractiveForce("(d * d) / k");
p.setRepulsiveForce("(k * k) / d");
p.setCriterion(15);
//p.setCriterion(criterionValue);
p.setCoolingRate(0.065);
p.setFrameDelay(5);
try {
ForceDirectedPlacement.simulate(graph, p);
}
catch(Exception ex) {
println("Exception: " + ex.getMessage());
}
}
void draw() {
background(55);
for (Vertex v : graph.vertexSet()) {
SimpleVertex sv = (SimpleVertex)v;
Vector2d pos = sv.getPos();
circle((float)pos.x, (float)pos.y, 20);
}
}
will also fix current java.util.concurrent.RejectedExecutionException when exiting chart window.
Hi,
I was wondering under what the license the code here is released. It would be helpful if the repository had a LICENSE file.
Thanks
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.