Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move GraphBuilder and all its logic from ddr #37

Merged
merged 3 commits into from
Oct 17, 2023
Merged
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
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ SOFTWARE.
<artifactId>annotations</artifactId>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
176 changes: 0 additions & 176 deletions src/main/kotlin/org/objectionary/deog/GraphBuilder.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
* SOFTWARE.
*/

package org.objectionary.deog.steps
package org.objectionary.deog.graph

import org.objectionary.deog.repr.DGraphNode
import org.objectionary.deog.repr.DeogGraph
import org.objectionary.deog.graph.repr.DGraphNode
import org.objectionary.deog.graph.repr.DeogGraph

/**
* Processes decoration cycles
*
* @param deogGraph graph to be analysed
* @param graph graph to be analysed
* @throws IllegalStateException if after the analysis it turns out that not all nodes of the graph were traversed
*/
@Throws(IllegalStateException::class)
internal fun processClosedCycles(deogGraph: DeogGraph) {
fun processClosedCycles(graph: DeogGraph) {
val reached: MutableMap<DGraphNode, Boolean> = mutableMapOf()
deogGraph.dgNodes.forEach { reached[it] = false }
deogGraph.heads.forEach { dfsReachable(it, reached) }
graph.dgNodes.forEach { reached[it] = false }
graph.heads.forEach { dfsReachable(it, reached) }
for (entry in reached) {
if (!entry.value) {
deogGraph.heads.add(entry.key)
graph.heads.add(entry.key)
traverseCycles(entry.key, reached)
}
}
if (deogGraph.dgNodes.size != reached.filter { it.value }.size) {
if (graph.dgNodes.size != reached.filter { it.value }.size) {
throw IllegalStateException(
"Not all nodes of inheritance graph were reached.\n " +
"Graph size: ${deogGraph.dgNodes.size}, reached nodes: ${reached.filter { it.value }.size}"
"Graph size: ${graph.dgNodes.size}, reached nodes: ${reached.filter { it.value }.size}"
)
}
}
Expand Down
Loading