use of jcog.data.graph.MapNodeGraph in project narchy by automenta.
the class NodeGraphTest method testObjectGraph.
@Test
public void testObjectGraph() {
MapNodeGraph<Object, Object> h = new MapNodeGraph<>();
h.addEdge(h.addNode("y"), "yx", h.addNode("x"));
ObjectGraph o = new ObjectGraph(3, h) {
@Override
protected boolean access(Object root, FasterList<Pair<Class, ObjectGraph.Accessor>> path, Object target) {
System.out.println(root + " -> " + target + "\n\t" + path);
return true;
}
@Override
public boolean includeValue(Object value) {
return true;
}
@Override
public boolean includeClass(Class<?> c) {
return !c.isPrimitive();
}
@Override
public boolean includeField(Field f) {
return true;
}
};
o.print();
}
use of jcog.data.graph.MapNodeGraph in project narchy by automenta.
the class NodeGraphTest method g1.
static NodeGraph g1() {
MapNodeGraph n = new MapNodeGraph();
n.addNode("a");
n.addNode("b");
n.addNode("c");
n.addNode("d");
n.addNode("e");
edge(n, "a", "b");
edge(n, "b", "c");
edge(n, "c", "d");
edge(n, "a", "e");
return n;
}
use of jcog.data.graph.MapNodeGraph in project narchy by automenta.
the class SimpleGraphTest method main.
public static void main(String[] args) {
MutableGraph g = GraphBuilder.directed().build();
g.putEdge(("a"), ("b"));
g.putEdge(("b"), ("c"));
g.putEdge(("b"), ("d"));
MapNodeGraph h = new MapNodeGraph();
h.addNode(("x"));
h.addNode(("y"));
h.addNode(("z"));
h.addNode(("w"));
h.addEdge(("x"), ("xy"), ("y"));
h.addEdge(("x"), ("xz"), ("z"));
h.addEdge(("y"), ("yz"), ("z"));
h.addEdge(("w"), ("wy"), ("y"));
SimpleGraph sg = new SimpleGraph();
// sg.commit(g);
sg.commit(h);
sg.show(800, 600, false);
}
use of jcog.data.graph.MapNodeGraph in project narchy by automenta.
the class TasksView method layoutTimeline.
public void layoutTimeline() {
final MapNodeGraph<Surface, String> graph = new MapNodeGraph();
float tScale = 100;
float tMin = tScale;
for (Surface cc : children()) {
// TODO make window content iteration method
TaskIcon c = (TaskIcon) cc;
Task t = c.task;
NodeGraph.MutableNode<Surface, String> tn = graph.addNode(c);
for (long e : t.stamp()) {
NodeGraph.Node en = graph.node(evidences.getIfAbsentPutWithKey(e, (ee) -> {
Surface s = new PushButton("_" + ee);
// TODO make evidence buttons visibility toggleable
// children.add(s);
graph.addNode(s);
return s;
}));
graph.addEdge((NodeGraph.MutableNode) en, "stamp", tn);
}
float minH = 30;
float maxH = 200;
float h = t.isQuestOrQuestion() ? Util.lerp(t.originality() / 2f, minH, maxH) : Util.lerp(t.originality() * t.conf(), minH, maxH);
long start, end;
if (!t.isEternal()) {
start = t.start();
end = t.end();
} else {
start = t.creation();
// TODO max time
end = 10;
}
float x1 = start * tScale;
float x2 = end * tScale;
if (x2 - x1 < tMin) {
float x = (x1 + x2) / 2f;
x1 = x - tMin / 2;
x2 = x + tMin / 2;
}
float y = (float) (Math.random() * 500);
c.pos(x1, y, x2, y + h);
}
graph.print();
new Thread(() -> {
int iterations = 300;
for (int i = 0; i < iterations; i++) {
layoutForceDirect(graph);
layout();
Util.sleep(5);
}
}).start();
}
Aggregations