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

it.unibo.alchemist.model.linkingrules.FullyConnected.kt Maven / Gradle / Ivy

Go to download

Abstract, incarnation independent implementations of the Alchemist's interfaces. Provides support for those who want to write incarnations.

There is a newer version: 35.0.1
Show newest version
/*
 * Copyright (C) 2010-2022, Danilo Pianini and contributors
 * listed, for each module, in the respective subproject's build.gradle.kts file.
 *
 * This file is part of Alchemist, and is distributed under the terms of the
 * GNU General Public License, with a linking exception,
 * as described in the file LICENSE in the Alchemist distribution's top directory.
 */

package it.unibo.alchemist.model.linkingrules

import com.google.common.collect.Iterators
import it.unibo.alchemist.model.Environment
import it.unibo.alchemist.model.LinkingRule
import it.unibo.alchemist.model.Neighborhood
import it.unibo.alchemist.model.Node
import it.unibo.alchemist.model.Position
import org.danilopianini.util.ListSet

/**
 * This rule connects each and every node to each and every other.
 */
class FullyConnected> : LinkingRule {
    override fun isLocallyConsistent() = true
    override fun computeNeighborhood(center: Node, environment: Environment) = object :
        Neighborhood {

        override fun contains(node: Node?) = node != center

        override fun getCenter() = center

        override fun isEmpty() = environment.nodeCount <= 1

        override fun getNeighbors() = object : ListSet> {
            override fun get(index: Int) = TODO()
            override fun indexOf(element: Node?) = TODO()
            override fun lastIndexOf(element: Node?) = TODO()
            override fun add(index: Int, element: Node?) = TODO()
            override fun addAll(index: Int, elements: Collection>) = TODO()
            override fun listIterator() = TODO()
            override fun listIterator(index: Int) = TODO()
            override fun removeAt(index: Int) = TODO()
            override fun set(index: Int, element: Node?) = TODO()
            override fun subList(fromIndex: Int, toIndex: Int) = TODO()
            override fun add(element: Node?) = TODO()
            override fun addAll(elements: Collection>) = TODO()
            override fun clear() = TODO()
            override fun iterator() = Iterators.filter(environment.nodes.iterator()) { it != center }
            override fun remove(element: Node?) = TODO()
            override fun removeAll(elements: Collection>) = TODO()
            override fun retainAll(elements: Collection>) = TODO()
            override val size = environment.nodeCount - 1
            override fun contains(element: Node?) = element != center && environment.contains(element)
            override fun containsAll(elements: Collection>) = elements.all { contains(it) }
            override fun isEmpty() = environment.nodeCount == 1
        }

        override fun remove(node: Node?) = this

        override fun add(node: Node?) = this

        override fun iterator() = neighbors.iterator()

        override fun size() = environment.nodeCount - 1
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy