All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.graph.subgraph.kt Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.8
Show newest version
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]) }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy