com.jtransc.graph.subgraph.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransc-core Show documentation
Show all versions of jtransc-core Show documentation
JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.
package com.jtransc.graph
fun Digraph.subgraph(from: T, to: T): Digraph {
return FilterDigraph(this) { graph, index, node ->
node != to
}
}
fun Digraph.subgraph(from: Int, to: Int): Digraph {
return FilterDigraph(this) { graph, index, node ->
index != to
}
}
class FilterDigraph(val graph: Digraph, val filter: (graph: Digraph, index:Int, node: T) -> Boolean) : Digraph {
override val nodes: List = graph.nodes
override val nodeIndices: Map = graph.nodeIndices
//override fun getIn(node: Int): List = graph.getIn(node).filter { filter(graph, it, nodes[it]) }
override fun getOut(node: Int): List = graph.getOut(node).filter { filter(graph, it, nodes[it]) }
}