graph

package
v0.0.0-...-44f780f Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFaultRoute

func DeleteFaultRoute(g Graph, fault_worker, selfId int)

mirror 点: 检查自己的master是否alive,如不alive替换为 mirrorBack 查看mirrorBack是不是自身,是自身读取对应的Master back路由信息 master点: 简单删除失效mirror点即可

func GetTargetsNum

func GetTargetsNum(targetsFile io.Reader) []int

func LoadBackGraph

func LoadBackGraph(g Graph, GBack, MasterBack io.Reader, faultId, selfId int)

Types

type Graph

type Graph interface {

	// GetNodeCount returns the total number of nodes.
	GetNodeCount() int

	// GetNode finds the Node. It returns nil if the Node
	// does not exist in the graph.
	GetNode(id int) Node

	// GetNodes returns a map from node int64 to
	// empty struct value. Graph does not allow duplicate
	// node int64 or name.
	GetNodes() map[int]Node

	// AddNode adds a node to a graph, and returns false
	// if the node already existed in the graph.
	AddNode(nd Node) bool

	// AddEdge adds an edge from nd1 to nd2 with the weight.
	// It returns error if a node does not exist.
	AddEdge(id1, id2 int, weight float32)

	IsMaster(id int) bool
	IsMirror(id int) bool

	AddMirror(id int, masterWR int)

	GetMirrors() map[int]int

	GetMirrorBacks() map[int]int

	AddMaster(id int, routeMsg []int)

	GetMasters() map[int][]int

	GetSources(id int) map[int]float32

	// GetTargets returns the map of child Nodes.
	// (Nodes that go out of the argument vertex.)
	GetTargets(id int) []int
	GetWeights(id int) []float32

	GetEdgeNum() int64
	GetBackNodes() []int
}

Graph describes the methods of graph operations. It assumes that the identifier of a Node is unique. And weight values is float64.

func NewGraphFromTXT

func NewGraphFromTXT(selfId, workerNum int, useTargets bool, is_rep bool) (Graph, error)

func NewPatternGraph

func NewPatternGraph(rd io.Reader) (Graph, error)

type Node

type Node interface {
	String() string
	Attr() int
	// contains filtered or unexported methods
}

Node is vertex. The int64 must be unique within the graph.

func NewNode

func NewNode(id int, attr int) Node

Jump to

Keyboard shortcuts

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