Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.cleanroommc.kirino.ecs.system.graph;

import com.google.common.graph.MutableNetwork;
import com.google.common.graph.NetworkBuilder;
import com.google.common.graph.Traverser;

@SuppressWarnings("UnstableApiUsage")
public class DirectAcyclicGraph {
final MutableNetwork<Node, Edge> graph;

public DirectAcyclicGraph() {
this.graph = NetworkBuilder.directed()
.allowsSelfLoops(false)
.allowsParallelEdges(true)
.build();
}
public void addEdge(Node from, Node to, Edge edge) {
Traverser.forGraph(graph.asGraph()).breadthFirst(to).forEach((node) -> {
if (node == from) {
throw new IllegalArgumentException("Connecting node" + from + "to" + to + "create a cycle!");
}
});
graph.addEdge(from, to, edge);
}

public void addNode(Node node) {
graph.addNode(node);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.cleanroommc.kirino.ecs.system.graph;

public class Edge {
public void function() {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package com.cleanroommc.kirino.ecs.system.graph;

public class SystemExeGraph {
import com.cleanroommc.kirino.ecs.job.JobScheduler;
import com.google.common.graph.Traverser;

public class SystemExeGraph extends DirectAcyclicGraph {

public SystemExeGraph() {
super();
}

public void execute() {

}
Expand Down