Graph Property Maps
-
Abstracts over storage location for values associated with graphs.
Graph algorithms often need to store data during the course of execution, such as vertex color (during search), or the costs of traversing an edge (e.g. Dijkstra’s algorithm). While some graph types can store data within the graph structure itself. (e.g.
AdjacencyListallows associating data with every vertex and edge.) Some graph data structures are not materialized whatsoever (e.g. the possible moves on a knight’s tour on a chess board). Additionally, data is often needed only during the course of an algorithm, and is discarded afterwards. As a result, it would be inefficient to pay the cost of requiring every graph implementation to persist this transient state. Fortunately, property maps allow us to leverage “in-graph” storage when it is available, while also allowing data to be stored outside the graph when convenient as well, all behind a single abstraction. In short, thanks to the PropertyMap protocol, we can write an algorithm once using one or more PropertyMap’s, and the algorithm can be re-used independent of whether the data is stored within the graph data structure or in a separate data structure.See moreSee also
ExternalPropertyMapDeclaration
Swift
public protocol PropertyMap -
External property maps store data outside the graph.
See moreDeclaration
Swift
public protocol ExternalPropertyMap : PropertyMap -
A
See moreParallelCapablePropertyMapis one that can be used withParallelGraphs in vertex-parallel algorithms.Declaration
Swift
public protocol ParallelCapablePropertyMap : PropertyMap where Self.Graph : ParallelGraph -
A table-based external property map.
See moreDeclaration
Swift
public struct TablePropertyMap<Graph: GraphProtocol, Key, Value>: ExternalPropertyMap where Key: IdIndexableextension TablePropertyMap: ParallelCapablePropertyMap where Graph: ParallelGraph -
An external property map backed by a dictionary.
See moreDeclaration
Swift
public struct DictionaryPropertyMap<Graph: GraphProtocol, Key, Value>: ExternalPropertyMap where Key: Hashableextension DictionaryPropertyMap: ParallelCapablePropertyMap where Graph: ParallelGraph -
A read-only property map whose values are computed by a closure.
See moreDeclaration
Swift
public struct ClosurePropertyMap<Graph, Key, Value> : ExternalPropertyMap where Graph : GraphProtocol -
Transforms an existing property map (
Underlying) to project out a single underlying field from itsValue.Beware: this results in extra copies when mutating the underlying values.
See moreSee also
PropertyMap.transform.Declaration
Swift
public struct TransformingPropertyMap<NewValue, Underlying> : PropertyMap where Underlying : PropertyMapextension TransformingPropertyMap: ParallelCapablePropertyMap where Underlying: ParallelCapablePropertyMap -
A
See morePropertyMapover the vertices ofGraph.Declaration
Swift
public struct InternalVertexPropertyMap<Graph> : PropertyMap where Graph : PropertyGraphextension InternalVertexPropertyMap: ParallelCapablePropertyMap where Graph: ParallelGraph, Graph.ParallelProjection: PropertyGraph, Graph.ParallelProjection.Vertex == Graph.Vertex -
A
See morePropertyMapover the edges ofGraph.Declaration
Swift
public struct InternalEdgePropertyMap<Graph> : PropertyMap where Graph : PropertyGraphextension InternalEdgePropertyMap: ParallelCapablePropertyMap where Graph: ParallelGraph, Graph.ParallelProjection: PropertyGraph, Graph.ParallelProjection.Edge == Graph.Edge
View on GitHub
Graph Property Maps Reference