loggersoft.kotlin.utils.graph.Path.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-utils Show documentation
Show all versions of kotlin-utils Show documentation
Helpful extra utils for the kotlin-std library.
/*
* Copyright (C) 2018 Alexander Kornilov ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loggersoft.kotlin.utils.graph
import loggersoft.kotlin.utils.IndexList
/**
* Represents a path in a graph.
*
* @author Alexander Kornilov ([email protected]).
*/
interface Path : IndexList>>, Comparable> {
/**
* A begin of the path.
*/
val startFrom: V
/**
* An end of the path.
*/
val endWith: V
/**
* A list of edges in the path from beginning to the end.
*/
val edges: List>
/**
* A total weight of the path.
*/
val weight: Double
/**
* Returns `true` if path contains [value] of a vertex; `false` otherwise.
*/
operator fun contains(value: V): Boolean = edges.any { it.startFrom == value || it.endWith == value }
/**
* [startFrom]
*/
operator fun component1() = startFrom
/**
* [endWith]
*/
operator fun component2() = endWith
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy