BidirectionalGraph
public protocol BidirectionalGraph : IncidenceGraph
A graph that allows retrieval of edges incoming to each vertex (the “in-edges”).
-
The collection of edges whose destinations are a given vertex (the “in-edges”).
Declaration
Swift
associatedtype VertexInEdgeCollection : Collection where Self.EdgeId == Self.VertexInEdgeCollection.Element -
Returns the collection of edges whose destination is
vertex.Declaration
Swift
func edges(to vertex: VertexId) -> VertexInEdgeCollection -
inDegree(of:Default implementation) Returns the number of “in-edges” of
vertex.Default Implementation
Returns the number of “in-edges” of
vertex.Declaration
Swift
func inDegree(of vertex: VertexId) -> Int -
degree(of:Default implementation) Returns the number of “in-edges” plus “out-edges” of
vertexinself.Default Implementation
Returns the number of “in-edges” plus “out-edges” of
vertexinself.Declaration
Swift
func degree(of vertex: VertexId) -> Int
-
kNNEnhancedHillClimbingSearch(query:Extension methodk: seeds: vertexVisitationState: workList: similarityBetween: ) Returns the
kapproximate nearest neighbors ofqueryinself.Note: the vertices are not guaranteed to be in similarity-order.
This algorithm is Algorithm 1 from k-NN Graph Construction: a Generic Online Approach, by Wan-Lei Zhao
Declaration
Swift
public mutating func kNNEnhancedHillClimbingSearch< Similarity: Comparable, Seeds: Collection, VertexVisitationState: PropertyMap, Heap, HeapIndexer >( query: VertexId, k: Int, seeds: Seeds, vertexVisitationState: inout VertexVisitationState, workList: GenericMaxPriorityQueue<Similarity, VertexId, Heap, HeapIndexer>, // TODO: Do truncation! similarityBetween: (VertexId, VertexId, inout Self) -> Similarity ) -> [(VertexId, Similarity)] where Seeds.Element == VertexId, VertexVisitationState.Graph == Self, VertexVisitationState.Key == VertexId, VertexVisitationState.Value == VertexColor -
transposed()Extension methodReturns a transposed representation of
self.A graph transpose is a graph of the same size and shape, but where the source and destination of every edge has simpliy been reversed.
To use property maps with the resulting transposed graph, simpliy wrap them in
TransposeGraphPropertyMapAdapter.Complexity
O(1)Declaration
Swift
public func transposed() -> TransposeGraph<Self>
-
inDegreeDistributionExtension methodComputes the distribution of in-degrees of all vertices in
self.Complexity
O(|V| + |E|)Declaration
Swift
public var inDegreeDistribution: DegreeDistribution { get }
-
clusteringCoefficient(of:Extension method) Returns the local clustering coefficient of the
neighborhoodassumingselfis a directed graph.Precondition
(Not checked)
vertexdoes not contain an edge to itself.See also
IncidenceGraph.undirectedClusteringCoefficientDeclaration
Swift
public func clusteringCoefficient(of vertex: VertexId) -> Double
-
averageClusteringCoefficientExtension methodThe unweighted average clustering coefficient of
self.Declaration
Swift
public var averageClusteringCoefficient: Double { get }
-
kNNEnhancedHillClimbingSearch(query:Extension methodk: seeds: similarityBetween: ) Returns the
kapproximate nearest neighbors ofqueryinself.Note: the vertices are not guaranteed to be in similarity-order!
This algorithm is Algorithm 1 from k-NN Graph Construction: a Generic Online Approach, by Wan-Lei Zhao
Declaration
Swift
public mutating func kNNEnhancedHillClimbingSearch<Similarity: Comparable, Seeds: Collection>( query: VertexId, k: Int, seeds: Seeds, similarityBetween: (VertexId, VertexId, inout Self) -> Similarity ) -> [(VertexId, Similarity)] where Seeds.Element == VertexId
-
kNNInsertApproximateKNearestNeighborEdges(for:Extension methodk: rng: similarities: similarityBetween: ) Adds
kedges tovertexcorresponding to approximately theknearest neighbors inselfaccording to the similarity functionsimilarityBetween; the similarities corresponding to thekedges are stored insimilarities.This algorithm is Algorithm 2 from k-NN Graph Construction: a Generic Online Approach, by Wan-Lei Zhao
Declaration
Swift
public mutating func kNNInsertApproximateKNearestNeighborEdges< Similarity: Comparable, RNG: RandomNumberGenerator, VertexSimilarities: PropertyMap >( for vertex: VertexId, k: Int, rng: inout RNG, similarities: inout VertexSimilarities, similarityBetween: (VertexId, VertexId, inout Self) -> Similarity ) -> [(VertexId, Similarity)] where VertexSimilarities.Graph == Self, VertexSimilarities.Key == EdgeId, VertexSimilarities.Value == SimilarityParameters
rngThe random number generator to use to select seeds.
-
Adds
kedges tovertexcorresponding to approximately theknearest neighbors inselfaccording to the similarity functionsimilarityBetween; the similarities corresponding to thekedges are stored insimilarities.This algorithm is Algorithm 2 from k-NN Graph Construction: a Generic Online Approach, by Wan-Lei Zhao
Declaration
Swift
public mutating func kNNInsertApproximateKNearestNeighborEdges< Similarity: Comparable, VertexSimilarities: PropertyMap >( for vertex: VertexId, k: Int, similarities: inout VertexSimilarities, similarityBetween: (VertexId, VertexId, inout Self) -> Similarity ) -> [(VertexId, Similarity)] where VertexSimilarities.Graph == Self, VertexSimilarities.Key == EdgeId, VertexSimilarities.Value == SimilarityParameters
rngThe random number generator to use to select seeds.
View on GitHub
BidirectionalGraph Protocol Reference