gographer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

go-grapher creates a graph using golang code. The visuaslization is outputed to html with d3. The data from d3 is updated via websockets. No need to refresh the page.

We have updated the websocket to use the std lib and consolidated the methods into a single golang package.

by Ray Bernard This program is a fork from https://github.com/fjukstad/gographer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddEdgeMessage

type AddEdgeMessage struct {
	Command string `json:"command,string"`
	Source  int    `json:"source,int"`
	Target  int    `json:"target,int"`
	Id      int    `json:"id,int"`
	Weight  int    `json:"weight,int"`
}

type AddNodeMessage

type AddNodeMessage struct {
	Command string `json:"command,string"`
	Id      int    `json:"id,int"`
	Name    string `json:"name,string"`
	Group   string `json:"group,string"`
	Size    int    `json:"size,string"`
}

type Client

type Client struct {
	Conn     *websocket.Conn
	Listener net.Listener
}

func NewClient

func NewClient(ip, port string) (c *Client, err error)

func (*Client) Receive

func (c *Client) Receive() string

func (*Client) Send

func (c *Client) Send(message string)

func (*Client) SendBytes

func (c *Client) SendBytes(message []byte)

type Edge

type Edge struct {
	Source   int          `json:"source,int"`
	Target   int          `json:"target,int"`
	Id       int          `json:"id,int"`
	Weight   int          `json:"weight,int"`
	Graphics EdgeGraphics `json:"graphics,omitempty"`
	// contains filtered or unexported fields
}

type EdgeGraphics

type EdgeGraphics struct {
	Type  string `json:"type,string"`
	Name  string `json:"name,string"`
	Value string `json:"value,string"`
}

type Graph

type Graph struct {
	Nodes map[string]*Node `json:"nodes,omitempty"`
	Edges map[string]*Edge `json:"edges,omitempty"`
	// contains filtered or unexported fields
}

gographer.go Begin

func NewG

func NewG() *Graph

func NewGraphAt

func NewGraphAt(port string) *Graph

The functionality of starting wsserver on specified port

func (*Graph) AddEdge

func (g *Graph) AddEdge(from, to, id, weight int)

Add edge between Source and Target Edge is uniquely identified by tuple (source, target, id)

func (*Graph) AddGraphicEdge

func (g *Graph) AddGraphicEdge(from, to, id, weight int, typ, name, value string)

func (*Graph) AddGraphicNode

func (g *Graph) AddGraphicNode(id int, name string, group int, size int,
	description string, fgcolor string, bgcolor string, shape string, x int,
	y int, height int, width int)

func (*Graph) AddNode

func (g *Graph) AddNode(id int, name string, group int, size int)

Node is uniquely identified by id

func (*Graph) BroadcastAddEdge

func (g *Graph) BroadcastAddEdge(e Edge)

func (*Graph) BroadcastAddNode

func (g *Graph) BroadcastAddNode(n Node)

func (*Graph) BroadcastRemoveEdge

func (g *Graph) BroadcastRemoveEdge(e Edge)

func (*Graph) BroadcastRemoveNode

func (g *Graph) BroadcastRemoveNode(n Node)

func (*Graph) BroadcastRenameNode

func (g *Graph) BroadcastRenameNode(n Node)

func (*Graph) DumpJSON

func (g *Graph) DumpJSON(filename string)

Write graph to json file

func (*Graph) GetNumberOfNodes

func (g *Graph) GetNumberOfNodes() (numberOfNodes int)

func (*Graph) Handler

func (g *Graph) Handler(conn *websocket.Conn)

This is invoked first for all new connections. * Output current graph state before giving out updates

func (*Graph) RemoveEdge

func (g *Graph) RemoveEdge(from, to, id int)

func (*Graph) RemoveNode

func (g *Graph) RemoveNode(nodeId int)

func (*Graph) RenameNode

func (g *Graph) RenameNode(nodeId int, name string)

func (*Graph) ServerInfo

func (g *Graph) ServerInfo() string

type InitGraphMessage

type InitGraphMessage struct {
	Command string `json:"command,string"`
	Graph   string `json:"graph,string"`
}

Communication.go Begin

type Node

type Node struct {
	Id       int          `json:"id,int"`
	Name     string       `json:"name,string"`
	Group    string       `json:"group,string"`
	Size     int          `json:"size,int"`
	Graphics NodeGraphics `json:"graphics,omitempty"`
	// contains filtered or unexported fields
}

type NodeGraphics

type NodeGraphics struct {
	Name    string `json:"name,string"`
	FGColor string `json:"fgcolor,string"`
	BGColor string `json:"bgcolor,string"`
	Shape   string `json:"shape,string"`
	X       int    `json:"x,int"`
	Y       int    `json:"y,int"`
	Height  int    `json:"height,int"`
	Width   int    `json:"width,int"`
}

type RemoveEdgeMessage

type RemoveEdgeMessage struct {
	Command string `json:"command,string"`
	Source  int    `json:"source,int"`
	Target  int    `json:"target,int"`
	Id      int    `json:"id,int"`
}

type RemoveNodeMessage

type RemoveNodeMessage struct {
	Command string `json:"command,string"`
	Id      int    `json:"id"`
}

type SetNodeNameMessage

type SetNodeNameMessage struct {
	Command string `json:"command,string"`
	Id      int    `json:"id,int"`
	Name    string `json:"name,int"`
}

type WSConnHandler

type WSConnHandler interface {
	Handler(conn *websocket.Conn)
}

type WSServer

type WSServer struct {
	Hub         *hub
	Server      *http.Server
	Conn        *connection
	ConnHandler WSConnHandler
}

func New

func New(ip, port string) (s *WSServer)

func (*WSServer) GetServerInfo

func (s *WSServer) GetServerInfo() string

func (*WSServer) SetConnectionHandler

func (s *WSServer) SetConnectionHandler(connHandler WSConnHandler)

connHandler is an optional connection handler that may be registered * to receive new connections before they are attached to the hub. * Can be nil if no connection handler is desired.

func (*WSServer) Start

func (s *WSServer) Start()

type WriteToJSON

type WriteToJSON struct {
	Nodes []*Node `json:"nodes,omitempty"`
	Edges []*Edge `json:"links,omitempty"`
}

Jump to

Keyboard shortcuts

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