graph

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2022 License: LGPL-2.1 Imports: 11 Imported by: 0

Documentation

Overview

package graph the graph to describe the hierarchical relationship between geometric objects.

Index

Constants

View Source
const (
	PNode = 1
	LNode = 2
	CNode = 4
	ANode = 8

	// DefaultCost default cost.
	DefaultCost = 1
)

node type

View Source
const (
	PointPoint = PNode + PNode
	PointLine  = PNode + LNode
	PointCLine = PNode + CNode
	PointPoly  = PNode + ANode

	LineLine  = LNode + LNode
	LineCLine = LNode + CNode
	LinePoly  = LNode + ANode
)

edge cost

Variables

This section is empty.

Functions

func GenerateSteric

func GenerateSteric(g Graph) (matrix.Steric, error)

GenerateSteric ...

func IntersectLine

func IntersectLine(m1, m2 matrix.LineMatrix) chain.CorrelationNodeResult

IntersectLine returns a Collection that represents that part of geometry A intersect with geometry B.

func IntersectLinePolygon

func IntersectLinePolygon(line matrix.LineMatrix, poly matrix.PolygonMatrix) chain.CorrelationNodeResult

IntersectLinePolygon returns a Collection that represents that part of geometry A intersect with geometry B.

func IntersectPolygons

func IntersectPolygons(poly1, poly2 matrix.PolygonMatrix) []chain.CorrelationNodeResult

IntersectPolygons returns a Collection that represents that part of geometry A intersect with geometry B.

func IntersectionHandle

func IntersectionHandle(m1, m2 matrix.Steric, g1, g2 Graph) error

IntersectionHandle handle graph with m1 and m2.

func IntersectmultiLines

func IntersectmultiLines(m1 matrix.LineMatrix, m2 []matrix.LineMatrix) chain.CorrelationNodeResult

IntersectmultiLines returns a Collection that represents that part of geometry A intersect with geometry B.

func RingNodeHandle

func RingNodeHandle(m1, m2 matrix.PolygonMatrix, g1, g2 Graph)

RingNodeHandle handle graph with m1 and m2.

Types

type Clip

type Clip struct {
	Arg      []matrix.Steric // the arg(s) of the operation
	ArgGraph []Graph
	IsDesc   bool
}

Clip ...

func ClipHandle

func ClipHandle(m0, m1 matrix.Steric) *Clip

ClipHandle handle graph with m1 and m2,returns graph of intersection , union, difference and sym difference.

func (*Clip) Difference

func (c *Clip) Difference() (Graph, error)

Difference returns a Graph that represents that part of Graph A that does not intersect with Graph B. One can think of this as GraphA - Intersection(A,B).

func (*Clip) Intersection

func (c *Clip) Intersection() (Graph, error)

Intersection Computes the Intersection of two Graph.

func (*Clip) SymDifference

func (c *Clip) SymDifference() (Graph, error)

SymDifference returns a Graph that represents the portions of A and B that do not intersect. It is called a symmetric difference because SymDifference(A,B) = SymDifference(B,A).

One can think of this as Union(A,B) - Intersection(A,B).

func (*Clip) Union

func (c *Clip) Union() (Graph, error)

Union Computes the Union of two Graph.

type Graph

type Graph interface {

	// Nodes Returns nodes.
	Nodes() []*Node

	// Edges Returns edges.
	Edges() []map[int]int

	// Degree Returns degrees(num Connected) of node.
	Degree(index int) int

	// Connected Returns degree of node.
	Connected(index int) int

	// AddNode add a node.
	AddNode(n *Node)

	// AddNodeType add a node with type.
	AddNodeType(n *Node, nodeType int)

	// AddEdge add a edge.
	AddEdge(n1, n2 *Node)

	// AddEdgeCost add a edge.
	AddEdgeCost(n1, n2 *Node, value int)

	// DeleteNode removes a node .
	DeleteNode(n *Node)

	// DeleteEdge removes an edge from n1 to n2.
	DeleteEdge(n1, n2 *Node)

	// Node tells if there is an node .
	Node(n *Node) (*Node, bool)

	// NodeIndex tells if there is an node index.
	NodeIndex(n *Node) (int, bool)

	// NodeByIndex tells if there is an node by index.
	NodeByIndex(index int) (*Node, bool)

	// Edge tells if there is an edge from n1 to n2.
	Edge(n1, n2 *Node) bool

	// Order returns the number of vertices in the graph.
	Order() int

	// Equals returns the true if g==g1.
	Equals(g1 Graph) bool

	// Proximity returns true if  if g-g1<DefaultTolerance.
	Proximity(g1 Graph) bool

	// Union  Computes the Union of two Graph.
	Union(graph Graph) (Graph, error)

	// Intersection  Computes the Intersection of two Graph.
	Intersection(graph Graph) (Graph, error)

	// Difference returns a Graph that represents that part of Graph A that does not intersect with Graph B.
	// One can think of this as GraphA - Intersection(A,B).
	Difference(graph Graph) (Graph, error)

	// SymDifference returns a Graph that represents the portions of A and B that do not intersect.
	// It is called a symmetric difference because SymDifference(A,B) = SymDifference(B,A).
	//
	// One can think of this as Union(A,B) - Intersection(A,B).
	SymDifference(graph Graph) (Graph, error)

	// String ...
	String() string
}

Graph represents a graph with a geometry of vertices and weighted edges that can be added or removed. The implementation uses hash maps to associate each vertex in the graph with its adjacent vertices. This gives constant time performance for all basic operations.

func GenerateGraph

func GenerateGraph(m matrix.Steric) (Graph, error)

GenerateGraph create graph with matrix.

func GenerateGraphCollection

func GenerateGraphCollection(m matrix.Steric) ([]Graph, error)

GenerateGraphCollection create graph with collection.

type IntersectionNodeUniqueArrayFilter

type IntersectionNodeUniqueArrayFilter struct {
	// contains filtered or unexported fields
}

IntersectionNodeUniqueArrayFilter A Filter that extracts a unique array.

func (*IntersectionNodeUniqueArrayFilter) Entities

func (u *IntersectionNodeUniqueArrayFilter) Entities() interface{}

Entities Returns the gathered Matrixes.

func (*IntersectionNodeUniqueArrayFilter) Filter

func (u *IntersectionNodeUniqueArrayFilter) Filter(entity interface{}) bool

Filter Performs an operation with the provided .

type MatrixGraph

type MatrixGraph struct {
	// contains filtered or unexported fields
}

MatrixGraph represents a graph with a geometry of vertices and weighted edges that can be added or removed. The implementation uses hash maps to associate each vertex in the graph with its adjacent vertices. This gives constant time performance for all basic operations.

func (*MatrixGraph) AddEdge

func (g *MatrixGraph) AddEdge(n1, n2 *Node)

AddEdge add a edge.

func (*MatrixGraph) AddEdgeCost

func (g *MatrixGraph) AddEdgeCost(n1, n2 *Node, value int)

AddEdgeCost add a edge.

func (*MatrixGraph) AddNode

func (g *MatrixGraph) AddNode(n *Node)

AddNode add a node.

func (*MatrixGraph) AddNodeType

func (g *MatrixGraph) AddNodeType(n *Node, nodeType int)

AddNodeType add a node with type.

func (*MatrixGraph) Connected

func (g *MatrixGraph) Connected(index int) int

Connected Returns num Connected of node.

func (*MatrixGraph) Degree

func (g *MatrixGraph) Degree(index int) int

Degree Returns degree of node.

func (*MatrixGraph) DeleteEdge

func (g *MatrixGraph) DeleteEdge(n1, n2 *Node)

DeleteEdge removes an edge from n1 to n2.

func (*MatrixGraph) DeleteEdgeByIndex

func (g *MatrixGraph) DeleteEdgeByIndex(n1, n2 int)

DeleteEdgeByIndex removes an edge from n1 to n2.

func (*MatrixGraph) DeleteNode

func (g *MatrixGraph) DeleteNode(n *Node)

DeleteNode removes a node.

func (*MatrixGraph) Difference

func (g *MatrixGraph) Difference(graph Graph) (Graph, error)

Difference returns a Graph that represents that part of Graph A that does not intersect with Graph B. One can think of this as GraphA - Intersection(A,B).

func (*MatrixGraph) Edge

func (g *MatrixGraph) Edge(n1, n2 *Node) bool

Edge tells if there is an edge from n1 to n2.

func (*MatrixGraph) Edges

func (g *MatrixGraph) Edges() []map[int]int

Edges Returns edges.

func (*MatrixGraph) Equals

func (g *MatrixGraph) Equals(g1 Graph) bool

Equals returns the true if g==g1.

func (*MatrixGraph) EqualsExact

func (g *MatrixGraph) EqualsExact(g1 Graph, tolerance float64) bool

EqualsExact returns the true if g-g1<tolerance.

func (*MatrixGraph) Intersection

func (g *MatrixGraph) Intersection(graph Graph) (Graph, error)

Intersection Computes the Intersection of two Graph.

func (*MatrixGraph) Node

func (g *MatrixGraph) Node(n *Node) (*Node, bool)

Node tells if there is an node .

func (*MatrixGraph) NodeByIndex

func (g *MatrixGraph) NodeByIndex(index int) (*Node, bool)

NodeByIndex tells if there is an node by index.

func (*MatrixGraph) NodeIndex

func (g *MatrixGraph) NodeIndex(n *Node) (int, bool)

NodeIndex tells if there is an node index.

func (*MatrixGraph) Nodes

func (g *MatrixGraph) Nodes() []*Node

Nodes Returns nodes.

func (*MatrixGraph) Order

func (g *MatrixGraph) Order() int

Order returns the number of vertices in the graph.

func (*MatrixGraph) Proximity

func (g *MatrixGraph) Proximity(g1 Graph) bool

Proximity returns true if if g-g1<DefaultTolerance.

func (*MatrixGraph) String

func (g *MatrixGraph) String() string

String ...

func (*MatrixGraph) SymDifference

func (g *MatrixGraph) SymDifference(graph Graph) (Graph, error)

SymDifference returns a Graph that represents the portions of A and B that do not intersect. It is called a symmetric difference because SymDifference(A,B) = SymDifference(B,A).

One can think of this as Union(A,B) - Intersection(A,B).

func (*MatrixGraph) Union

func (g *MatrixGraph) Union(graph Graph) (Graph, error)

Union Computes the Union of two Graph.

type Merge added in v1.1.1

type Merge struct {
	Arg      []matrix.Steric // the arg(s) of the operation
	ArgGraph []Graph
	IsDesc   bool
}

Merge ...

func MergeHandle added in v1.1.1

func MergeHandle(m0, m1 matrix.Steric) *Merge

MergeHandle handle graph with m1 and m2,returns graph of intersection , union, difference and sym difference.

func (*Merge) Difference added in v1.1.1

func (c *Merge) Difference() (Graph, error)

Difference returns a Graph that represents that part of Graph A that does not intersect with Graph B. One can think of this as GraphA - Intersection(A,B).

func (*Merge) Intersection added in v1.1.1

func (c *Merge) Intersection() (Graph, error)

Intersection Computes the Intersection of two Graph.

func (*Merge) SymDifference added in v1.1.1

func (c *Merge) SymDifference() (Graph, error)

SymDifference returns a Graph that represents the portions of A and B that do not intersect. It is called a symmetric difference because SymDifference(A,B) = SymDifference(B,A).

One can think of this as Union(A,B) - Intersection(A,B).

func (*Merge) Union added in v1.1.1

func (c *Merge) Union() (Graph, error)

Union Computes the Union of two Graph.

type Node

type Node struct {
	Index   int
	Value   matrix.Steric
	Reverse matrix.Steric
	Stat    bool

	NodeType int
	// contains filtered or unexported fields
}

Node represents a node of a graph

func (*Node) Equals

func (n *Node) Equals(other *Node) bool

Equals returns the true if n==other.

func (*Node) EqualsExact

func (n *Node) EqualsExact(other *Node, tolerance float64) bool

EqualsExact returns the true if n-other<tolerance.

func (*Node) Proximity

func (n *Node) Proximity(other *Node) bool

Proximity returns true if if n-other<DefaultTolerance.

Directories

Path Synopsis
Package clipping the spatial geometric operation and reconstruction between entities is realized.
Package clipping the spatial geometric operation and reconstruction between entities is realized.
package de9im the criteria for judging the various topological relations between points, line and surface entities in DE-9IM model are given.
package de9im the criteria for judging the various topological relations between points, line and surface entities in DE-9IM model are given.
Package dissovle Slice a geometric polygon.
Package dissovle Slice a geometric polygon.
package graphtests is include test datas.
package graphtests is include test datas.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL