gograph

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 6 Imported by: 0

README

Go Reference

GoGraph

  • graph data structure that is compatible with javascript's SigmaJS and Graphology
  • Adding/Removing nodes and edges
  • Import/Export graph as JSON

How to Use

go get -u github.com/UserJY/GoGraph
package main

import "github.com/UserJY/GoGraph" 

func main(){
	somegraph := gograph.MakeRandomGraph()
	
	somegraph.Print()
  	somegraph.ExportJSON("out.json")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	Key        string   `json:"key,omitempty"`
	Source     string   `json:"source"`
	Target     string   `json:"target"`
	Attributes EdgeAttr `json:"attributes,omitempty"`
}

func (*Edge) Print

func (edge *Edge) Print()

func (*Edge) ToAOB

func (edge *Edge) ToAOB() []byte

func (*Edge) ToString

func (edge *Edge) ToString() string

type EdgeAttr

type EdgeAttr struct {
	Size int    `json:"size,omitempty"`
	Type string `json:"type,omitempty"`
}

type Node

type Node struct {
	Key        string   `json:"key"`
	Attributes NodeAttr `json:"attributes"`
}

func (*Node) Print

func (node *Node) Print()

func (*Node) ToAOB

func (node *Node) ToAOB() []byte

func (*Node) ToString

func (node *Node) ToString() string

type NodeAttr

type NodeAttr struct {
	X     int    `json:"x"`
	Y     int    `json:"y"`
	Size  uint   `json:"size,omitempty"`
	Label string `json:"label,omitempty"`
	Color string `json:"color,omitempty"`
}

type SigmaGraph

type SigmaGraph struct {
	Nodes []Node `json:"nodes"`
	Edges []Edge `json:"edges,omitempty"`
}

func ImportJSON

func ImportJSON(filepath string) SigmaGraph

func MakeRandomGraph

func MakeRandomGraph() SigmaGraph

func (*SigmaGraph) AddEdge

func (mygraph *SigmaGraph) AddEdge(src string, tgt string)

func (*SigmaGraph) AddNode

func (mygraph *SigmaGraph) AddNode(myinput string, nX int, nY int, nSize uint)

func (*SigmaGraph) AddRandomNode

func (mygraph *SigmaGraph) AddRandomNode(myinput string)

func (*SigmaGraph) BuildNodeHashmap

func (mygraph *SigmaGraph) BuildNodeHashmap() map[string]*Node

func (*SigmaGraph) ExportJSON

func (mygraph *SigmaGraph) ExportJSON(filepath string)

func (*SigmaGraph) ImportJSON

func (mygraph *SigmaGraph) ImportJSON(filepath string)

func (*SigmaGraph) Print

func (mygraph *SigmaGraph) Print()

func (*SigmaGraph) ToAOB

func (mygraph *SigmaGraph) ToAOB() []byte

func (*SigmaGraph) ToString

func (mygraph *SigmaGraph) ToString() string

Jump to

Keyboard shortcuts

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