Latest 0.2.0
Homepage https://github.com/soutaro/Gunma
License MIT
Platforms ios 8.0, requires ARC
Authors

Build Status

Gunma is a graph library for Swift. It provides basic graph structure and implementations for Strongly Connected Components and Topological Sort.

// From https://en.wikipedia.org/wiki/Strongly_connected_component

var graph = Graph<String>()

graph.addVertex("a")
graph.addVertex("b")
graph.addVertex("c")
graph.addVertex("d")
graph.addVertex("e")
graph.addVertex("f")
graph.addVertex("g")
graph.addVertex("h")

graph.addEdge(from: "a", to: "b")
graph.addEdge(from: "b", to: "c")
graph.addEdge(from: "b", to: "f")
graph.addEdge(from: "b", to: "e")
graph.addEdge(from: "c", to: "d")
graph.addEdge(from: "c", to: "g")
graph.addEdge(from: "d", to: "c")
graph.addEdge(from: "d", to: "h")
graph.addEdge(from: "e", to: "a")
graph.addEdge(from: "e", to: "f")
graph.addEdge(from: "f", to: "g")
graph.addEdge(from: "g", to: "f")
graph.addEdge(from: "h", to: "d")
graph.addEdge(from: "f", to: "g")

// New graph for strongly connected components of graph
let scc: Graph<Set<String>> = Graph.stronglyConnectedComponents(graph)

// List of topologically sorted vertices
let array: [String] = try Graph.topologicalSort(graph)

Cocoapods

pod "Gunma"

Author

Soutaro Matsumoto [email protected]

Latest podspec

{
    "name": "Gunma",
    "version": "0.2.0",
    "license": "MIT",
    "homepage": "https://github.com/soutaro/Gunma",
    "authors": {
        "Soutaro Matsumoto": "[email protected]"
    },
    "summary": "Graph Library for Swift",
    "source": {
        "git": "https://github.com/soutaro/Gunma.git",
        "tag": "0.2.0"
    },
    "source_files": "Gunma/*.swift",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    }
}

Pin It on Pinterest

Share This