Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.
mattt edited this page Jan 7, 2021 · 12 revisions

Graph

@dynamicMemberLookup public struct Graph: Equatable

Inheritance

Equatable

Initializers

init(directed:strict:)

Creates a graph.

public init(directed: Bool = false, strict: Bool = false)

Parameters

  • directed: Whether the graph is directed; false by default.
  • strict: Whether the graph is strict; false by default.

init(directed:strict:_:)

public init(directed: Bool = false, strict: Bool = false, _ builder: () -> GraphMember)

Properties

directed

Whether the graph is directed.

var directed: Bool

strict

Whether the graph is strict.

var strict: Bool

id

The id of the graph, is any.

var id: String? = nil

subgraphs

Subgraphs contained by the graph.

var subgraphs: [Subgraph] = []

nodes

Nodes contained by the graph.

var nodes: [Node] = []

edges

Edges contained by the graph.

var edges: [Edge] = []

isEmpty

Returns whether the graph is empty.

var isEmpty: Bool

A graph is considered to be empty if it has no subgraphs, has no edges, has no nodes with attributes, and has no attributes itself.

attributes

var attributes: Attributes

Methods

append(_:)

public mutating func append(_ subgraph: Subgraph)

append(contentsOf:)

public mutating func append<S>(contentsOf subgraphs: S) where S.Element == Subgraph, S: Sequence

append(_:)

public mutating func append(_ node: Node)

append(contentsOf:)

public mutating func append<S>(contentsOf nodes: S) where S.Element == Node, S: Sequence

append(_:)

public mutating func append(_ edge: Edge)

append(contentsOf:)

public mutating func append<S>(contentsOf edges: S) where S.Element == Edge, S: Sequence

render(using:to:with:)

Renders the graph using the specified layout algorithm to the desired output format.

public func render(using layout: LayoutAlgorithm, to format: Format, with options: Renderer.Options = []) throws -> Data

Parameters

  • layout: The layout algorithm.
  • format: The output format.
  • options: The rendering options.

Throws

CocoaError if the corresponding GraphViz tool isn't available.

Clone this wiki locally