WeightedGraph

org.appliedtopology.tda4j.WeightedGraph
See theWeightedGraph companion object
class WeightedGraph extends FiniteMetricSpace[Int]

A weighted undirected graph on the vertices 0 until n, held as sorted neighbour lists: n + 2 m numbers for m edges, where a distance matrix holds n^2. It is a metric space in the sense the Vietoris-Rips machinery needs: the distance of two vertices is 0 for the same vertex, the weight of the edge between them, and Infinity where there is none (the triangle inequality does not hold; this is the combinatorial reading, the flag complex of the listed edges). Persistence(graph) computes that flag complex with FlagComplex, without ever forming a matrix.

val graph = WeightedGraph(4, Seq((0, 1, 1.0), (1, 2, 1.5), (2, 3, 1.0), (3, 0, 2.0)))
Persistence(graph).dim(1)   // the square is a loop: born when its last edge enters, at 2.0, never filled

Attributes

See also

GraphMetric.geodesic for the shortest-path distances of a graph, which are a metric

Companion
object
Experimental
true
Source
WeightedGraph.scala
Graph
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def contains(x: Int): Boolean

Attributes

Source
WeightedGraph.scala
def distance(x: Int, y: Int): Double

The weight of the edge between x and y, 0 if they are the same vertex, Infinity if there is no edge.

The weight of the edge between x and y, 0 if they are the same vertex, Infinity if there is no edge.

Attributes

Source
WeightedGraph.scala
def edgeCount: Int

The number of edges.

The number of edges.

Attributes

Source
WeightedGraph.scala
def edges: Iterator[(Int, Int, Double)]

The edges (a, b, weight) with a < b, ascending by a and then b.

The edges (a, b, weight) with a < b, ascending by a and then b.

Attributes

Source
WeightedGraph.scala
def elements: Iterable[Int]

Access to all points in the metric space. Implemented by eg scala.collections.Range for simple Int-indexed spaces, but this definition gives more space for different underlying possible representations.

Access to all points in the metric space. Implemented by eg scala.collections.Range for simple Int-indexed spaces, but this definition gives more space for different underlying possible representations.

Attributes

Returns

Iterable that returns all points in the metric space

Source
WeightedGraph.scala
def neighbours(v: Int): Iterator[(Int, Double)]

The neighbours of v with the weights of their edges, ascending by neighbour.

The neighbours of v with the weights of their edges, ascending by neighbour.

Attributes

Source
WeightedGraph.scala
def size: Int

Number of points represented by this metric space.

Number of points represented by this metric space.

Attributes

Source
WeightedGraph.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
WeightedGraph.scala

Inherited methods

def longestDistanceWithin(threshold: Double): Double

The longest distance between two points of the space that is at most threshold, 0.0 when no two points are that close: the longest edge of the Vietoris-Rips complex truncated at threshold, which is the last filtration value of its graph.

The longest distance between two points of the space that is at most threshold, 0.0 when no two points are that close: the longest edge of the Vietoris-Rips complex truncated at threshold, which is the last filtration value of its graph.

One pass over the pairs, n^2 / 2 distances. A space that finds it faster overrides this and answers the same number (EuclideanMetricSpace does, by neighbour queries on a cloud too big to cache its distances); a threshold of NaN or below 0 finds no pair.

Attributes

Inherited from:
FiniteMetricSpace
Source
FiniteMetricSpace.scala
def neighbourListsWithin(threshold: Double, maxEntries: Long): Option[NeighbourLists]

Each point's neighbours within threshold, ascending, with their distances (NeighbourLists), when this space finds them faster than the pass over all pairs (NeighbourLists.within, which is what a caller runs on None): the lists the pass would build, entry for entry and to the last bit of each distance. None when the space has no faster way, or when there would be more than maxEntries directed pairs (the lists would not be sparse). EuclideanMetricSpace answers by one neighbour query per point on a cloud too big to cache its distances.

Each point's neighbours within threshold, ascending, with their distances (NeighbourLists), when this space finds them faster than the pass over all pairs (NeighbourLists.within, which is what a caller runs on None): the lists the pass would build, entry for entry and to the last bit of each distance. None when the space has no faster way, or when there would be more than maxEntries directed pairs (the lists would not be sparse). EuclideanMetricSpace answers by one neighbour query per point on a cloud too big to cache its distances.

Attributes

Inherited from:
FiniteMetricSpace
Source
FiniteMetricSpace.scala

Concrete fields

val n: Int

Attributes

Source
WeightedGraph.scala

Inherited fields

lazy val minimumEnclosingRadius: Double

Beyond this radius, the Vietoris-Rips complex is a cone and will have no further homological structure. See e.g. the Ripser paper, page 412. The same holds for the Cech and alpha complexes, whose union of balls is then contractible, so no barcode changes past it: it is the radius that Persistence runs to when it is not told another. A space with infinite distances (a sparse distance matrix: a pair that is not listed has no edge) has no such cone; its radius is then the largest finite distance, past which nothing enters.

Beyond this radius, the Vietoris-Rips complex is a cone and will have no further homological structure. See e.g. the Ripser paper, page 412. The same holds for the Cech and alpha complexes, whose union of balls is then contractible, so no barcode changes past it: it is the radius that Persistence runs to when it is not told another. A space with infinite distances (a sparse distance matrix: a pair that is not listed has no edge) has no such cone; its radius is then the largest finite distance, past which nothing enters.

Found by looking for the point whose farthest point is nearest, with no allocation, and giving up on a point as soon as a point at least as far as the best so far turns up: on spread-out points that takes a handful of distances per point, not all of them.

Attributes

Inherited from:
FiniteMetricSpace
Source
FiniteMetricSpace.scala