graphalg

package
v0.0.0-...-1b8f739 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2016 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package graphalg implements a set of structs and interfaces for running graph algorithms over sets of nodes and edges.

Package graphalg is a generated protocol buffer package.

It is generated from these files:

graphalg.proto

It has these top-level messages:

Weight
Message
SendMessageRequest
Error
SendMessageResponse
TestMessage
EdgeWeightRequest
EdgeWeightResponse

Index

Constants

This section is empty.

Variables

View Source
var WeightInf = Weight{Cost: math.Inf(1)}

WeightInf is an edge with infinite weight

Functions

func Join

func Join(n1 *Node, n2 *Node, w float64, f SenderRecieverMaker)

func MakeChanPair

func MakeChanPair() (SenderReciever, SenderReciever)

MakeChanPair is an edge sender/reciever built using a channel

func MakeDelayChanPair

func MakeDelayChanPair(d time.Duration) (SenderReciever, SenderReciever)

func NewEdge

func NewEdge(f SenderRecieverMaker) (*Edge, *Edge)

func RegisterMessage

func RegisterMessage(i interface{}) string

func RegisterMessageServiceServer

func RegisterMessageServiceServer(s *grpc.Server, srv MessageServiceServer)

func Run

func Run(a NodeAlgorithm, onDone func())

Types

type Base

type Base struct {
	IsDone bool
	OnDone func()
}

func (*Base) Done

func (b *Base) Done() bool

func (*Base) SetDone

func (b *Base) SetDone(done bool)

type ByMinEdge

type ByMinEdge []*Edge

ByMinEdge - implements sort by minimum edge

func (ByMinEdge) Len

func (e ByMinEdge) Len() int

func (ByMinEdge) Less

func (e ByMinEdge) Less(i, j int) bool

func (ByMinEdge) Swap

func (e ByMinEdge) Swap(i, j int)

type Closer

type Closer interface {
	Close()
}

type Dispatcher

type Dispatcher interface {
	Dispatch(edge int, m interface{})
	Edges() Edges
	Queued() []QueuedMessage
	ClearQueue()
}

type Doner

type Doner interface {
	Done() bool
}

type Edge

type Edge struct {
	Weight   Weight
	Disabled bool

	SenderReciever
	// contains filtered or unexported fields
}

func (*Edge) EdgeMessage

func (e *Edge) EdgeMessage(s string, d tracer.MessageDir)

func (*Edge) EdgeUpdate

func (e *Edge) EdgeUpdate()

func (*Edge) Recieve

func (e *Edge) Recieve() (interface{}, error)

func (*Edge) Send

func (e *Edge) Send(m MessageMarshaler)

func (Edge) String

func (e Edge) String() string

type EdgeWeightRequest

type EdgeWeightRequest struct {
	From   string         `protobuf:"bytes,1,opt,name=From,json=from" json:"From,omitempty"`
	To     string         `protobuf:"bytes,2,opt,name=To,json=to" json:"To,omitempty"`
	Gid    *graph.GraphID `protobuf:"bytes,3,opt,name=gid" json:"gid,omitempty"`
	Weight *Weight        `protobuf:"bytes,4,opt,name=weight" json:"weight,omitempty"`
}

func (*EdgeWeightRequest) Descriptor

func (*EdgeWeightRequest) Descriptor() ([]byte, []int)

func (*EdgeWeightRequest) GetGid

func (m *EdgeWeightRequest) GetGid() *graph.GraphID

func (*EdgeWeightRequest) GetWeight

func (m *EdgeWeightRequest) GetWeight() *Weight

func (*EdgeWeightRequest) ProtoMessage

func (*EdgeWeightRequest) ProtoMessage()

func (*EdgeWeightRequest) Reset

func (m *EdgeWeightRequest) Reset()

func (*EdgeWeightRequest) String

func (m *EdgeWeightRequest) String() string

type EdgeWeightResponse

type EdgeWeightResponse struct {
	Error  *Error  `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
	Weight *Weight `protobuf:"bytes,2,opt,name=weight" json:"weight,omitempty"`
}

func (*EdgeWeightResponse) Descriptor

func (*EdgeWeightResponse) Descriptor() ([]byte, []int)

func (*EdgeWeightResponse) GetError

func (m *EdgeWeightResponse) GetError() *Error

func (*EdgeWeightResponse) GetWeight

func (m *EdgeWeightResponse) GetWeight() *Weight

func (*EdgeWeightResponse) ProtoMessage

func (*EdgeWeightResponse) ProtoMessage()

func (*EdgeWeightResponse) Reset

func (m *EdgeWeightResponse) Reset()

func (*EdgeWeightResponse) String

func (m *EdgeWeightResponse) String() string

type Edges

type Edges []*Edge

func (Edges) MinEdge

func (e Edges) MinEdge() int

func (Edges) SortByMinEdge

func (e Edges) SortByMinEdge()

func (Edges) String

func (es Edges) String() string

type Error

type Error struct {
	Error int32  `protobuf:"varint,1,opt,name=error" json:"error,omitempty"`
	Msg   string `protobuf:"bytes,2,opt,name=msg" json:"msg,omitempty"`
}

func (*Error) Descriptor

func (*Error) Descriptor() ([]byte, []int)

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) Reset

func (m *Error) Reset()

func (*Error) String

func (m *Error) String() string

type Message

type Message struct {
	Payload *google_protobuf.Any `protobuf:"bytes,4,opt,name=Payload,json=payload" json:"Payload,omitempty"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetPayload

func (m *Message) GetPayload() *google_protobuf.Any

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type MessageMarshaler

type MessageMarshaler interface {
	MarshalMessage() ([]byte, string)
}

type MessageServiceClient

type MessageServiceClient interface {
	SendMessage(ctx context.Context, in *SendMessageRequest, opts ...grpc.CallOption) (*SendMessageResponse, error)
	EdgeWeight(ctx context.Context, in *EdgeWeightRequest, opts ...grpc.CallOption) (*EdgeWeightResponse, error)
}

func NewMessageServiceClient

func NewMessageServiceClient(cc *grpc.ClientConn) MessageServiceClient

type MessageServiceServer

type MessageServiceServer interface {
	SendMessage(context.Context, *SendMessageRequest) (*SendMessageResponse, error)
	EdgeWeight(context.Context, *EdgeWeightRequest) (*EdgeWeightResponse, error)
}

func NewGRPCServer

func NewGRPCServer() MessageServiceServer

type Node

type Node struct {
	Base
	ID NodeID

	*tracer.Tracer
	// contains filtered or unexported fields
}

func (*Node) ClearQueue

func (n *Node) ClearQueue()

func (*Node) Edge

func (n *Node) Edge(j int) *Edge

func (*Node) Edges

func (n *Node) Edges() Edges

func (*Node) Join

func (n1 *Node) Join(n2 *Node, w float64, f SenderRecieverMaker)

func (*Node) Log

func (n *Node) Log(s string)

func (*Node) MinEdge

func (n *Node) MinEdge() int

func (*Node) NodeUpdate

func (n *Node) NodeUpdate(s string)

func (*Node) Print

func (n *Node) Print(v ...interface{})

func (*Node) Printf

func (n *Node) Printf(str string, v ...interface{})

func (*Node) Println

func (n *Node) Println(v ...interface{})

func (*Node) Queue

func (n *Node) Queue(e int, d interface{})

Queue - re-queue a message to the internal queue

func (*Node) Queued

func (n *Node) Queued() []QueuedMessage

func (*Node) Send

func (n *Node) Send(e int, d MessageMarshaler)

Send - send a message to the specified

type NodeAlgorithm

type NodeAlgorithm interface {
	Dispatcher
	Doner
}

type NodeID

type NodeID string

type QueuedMessage

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

type Queuer

type Queuer interface {
	Queue(edge int, m interface{})
}

type Reciever

type Reciever interface {
	Recieve() (interface{}, error)
}

type SendMessageRequest

type SendMessageRequest struct {
	From string             `protobuf:"bytes,1,opt,name=From,json=from" json:"From,omitempty"`
	To   string             `protobuf:"bytes,2,opt,name=To,json=to" json:"To,omitempty"`
	Gid  *graph.GraphID     `protobuf:"bytes,3,opt,name=gid" json:"gid,omitempty"`
	Aid  *graph.AlgorithmID `protobuf:"bytes,4,opt,name=aid" json:"aid,omitempty"`
	Msg  *Message           `protobuf:"bytes,5,opt,name=msg" json:"msg,omitempty"`
}

func (*SendMessageRequest) Descriptor

func (*SendMessageRequest) Descriptor() ([]byte, []int)

func (*SendMessageRequest) GetAid

func (m *SendMessageRequest) GetAid() *graph.AlgorithmID

func (*SendMessageRequest) GetGid

func (m *SendMessageRequest) GetGid() *graph.GraphID

func (*SendMessageRequest) GetMsg

func (m *SendMessageRequest) GetMsg() *Message

func (*SendMessageRequest) ProtoMessage

func (*SendMessageRequest) ProtoMessage()

func (*SendMessageRequest) Reset

func (m *SendMessageRequest) Reset()

func (*SendMessageRequest) String

func (m *SendMessageRequest) String() string

type SendMessageResponse

type SendMessageResponse struct {
	Error *Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
}

func (*SendMessageResponse) Descriptor

func (*SendMessageResponse) Descriptor() ([]byte, []int)

func (*SendMessageResponse) GetError

func (m *SendMessageResponse) GetError() *Error

func (*SendMessageResponse) ProtoMessage

func (*SendMessageResponse) ProtoMessage()

func (*SendMessageResponse) Reset

func (m *SendMessageResponse) Reset()

func (*SendMessageResponse) String

func (m *SendMessageResponse) String() string

type Sender

type Sender interface {
	Send(MessageMarshaler)
}

type SenderReciever

type SenderReciever interface {
	Sender
	Reciever
	Closer
}

func MakeGRPCEdge

func MakeGRPCEdge(g graph.GraphID, a graph.AlgorithmID) SenderReciever

MakeGRPCEdge is an edge sender/reciever built using a channel

type SenderRecieverMaker

type SenderRecieverMaker func() (SenderReciever, SenderReciever)

type TestMessage

type TestMessage struct {
	Value int32 `protobuf:"varint,1,opt,name=Value,json=value" json:"Value,omitempty"`
}

func (*TestMessage) Descriptor

func (*TestMessage) Descriptor() ([]byte, []int)

func (*TestMessage) ProtoMessage

func (*TestMessage) ProtoMessage()

func (*TestMessage) Reset

func (m *TestMessage) Reset()

func (*TestMessage) String

func (m *TestMessage) String() string

type Weight

type Weight struct {
	Cost float64 `protobuf:"fixed64,1,opt,name=Cost,json=cost" json:"Cost,omitempty"`
	Lsn  string  `protobuf:"bytes,2,opt,name=Lsn,json=lsn" json:"Lsn,omitempty"`
	Msn  string  `protobuf:"bytes,3,opt,name=Msn,json=msn" json:"Msn,omitempty"`
}

func (*Weight) Descriptor

func (*Weight) Descriptor() ([]byte, []int)

func (Weight) Equal

func (w1 Weight) Equal(w2 Weight) bool

Less - compare two edge weights.

func (Weight) Greater

func (w1 Weight) Greater(w2 Weight) bool

Less - compare two edge weights.

func (Weight) Less

func (w1 Weight) Less(w2 Weight) bool

Less - compare two edge weights.

func (*Weight) ProtoMessage

func (*Weight) ProtoMessage()

func (*Weight) Reset

func (m *Weight) Reset()

func (*Weight) String

func (m *Weight) String() string

Jump to

Keyboard shortcuts

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