graph

package
v0.0.0-...-d7c879d Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DenseGraph

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

使用邻接矩阵的方式表示稠密图, 无权图 邻接矩阵能表达自环边和处理平行边的问题,能表示自环边,能过滤掉平行边

func CreateDenseGraph

func CreateDenseGraph(n int, directed bool) *DenseGraph
	创建稠密图
	n 顶点的数量
    directed 是否是有向图

func (*DenseGraph) AddEdge

func (graph *DenseGraph) AddEdge(v int, w int)

添加边,也就是连接两个顶点

func (DenseGraph) E

func (graph DenseGraph) E() int

边的数量

func (DenseGraph) HasEdge

func (graph DenseGraph) HasEdge(v int, w int) bool

检查边是否存在

func (*DenseGraph) RemoveEdge

func (graph *DenseGraph) RemoveEdge(v int, w int)

删除边

func (DenseGraph) V

func (graph DenseGraph) V() int

顶点数量

func (*DenseGraph) VertexIterator

func (graph *DenseGraph) VertexIterator(v int) common.ForIntIterator

获取某一个顶点相邻顶点的迭代器

type DenseVertexIterator

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

func (*DenseVertexIterator) Begin

func (iterator *DenseVertexIterator) Begin() int

func (*DenseVertexIterator) End

func (iterator *DenseVertexIterator) End() bool

func (*DenseVertexIterator) Next

func (iterator *DenseVertexIterator) Next() int

type SparseGraph

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

使用邻接表的形式表示稀疏图 邻接表的表示方式能表达自环边,但是不能以O(1)的方式处理平行边

func CreateSparseGraph

func CreateSparseGraph(n int, directed bool) *SparseGraph

func (*SparseGraph) AddEdge

func (graph *SparseGraph) AddEdge(v int, w int)

添加边 无法以O(1)的方式处理平行边的问题

func (SparseGraph) E

func (graph SparseGraph) E() int

边的数量

func (SparseGraph) V

func (graph SparseGraph) V() int

顶点数量

func (*SparseGraph) VertexIterator

func (graph *SparseGraph) VertexIterator(v int) common.ForIntIterator

获取某一个顶点相邻顶点的迭代器

type SparseVertexIterator

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

func (*SparseVertexIterator) Begin

func (iterator *SparseVertexIterator) Begin() int

func (*SparseVertexIterator) End

func (iterator *SparseVertexIterator) End() bool

func (*SparseVertexIterator) Next

func (iterator *SparseVertexIterator) Next() int

Jump to

Keyboard shortcuts

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