graphml

package
v1.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEdgeDoesNotExist   = errors.New("edge does not exist")
	ErrNodeDoesNotExist   = errors.New("node does not exist")
	ErrEdgeAlreadyExists  = errors.New("edge already exists")
	ErrNodeDataAlreadySet = errors.New("node data already set, will not override")
	ErrEdgeDataAlreadySet = errors.New("edge data already set, will not override")
)

Functions

This section is empty.

Types

type Data

type Data struct {
	Key   string `xml:"key,attr"`
	Value string `xml:",chardata"`
}

type Edge

type Edge struct {
	Source string `xml:"source,attr"`
	Target string `xml:"target,attr"`
	Data   Data   `xml:"data"`
}

type EdgeKey

type EdgeKey struct {
	Source, Target string
}

type Graph

type Graph struct {
	Nodes map[string]*Node
	Edges map[EdgeKey]*Edge
}

func NewGraph

func NewGraph() *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(source, target string) error

func (*Graph) GetEdge

func (g *Graph) GetEdge(source, target string) (*Edge, error)

func (*Graph) GetNode

func (g *Graph) GetNode(id string) (*Node, error)

func (*Graph) SetEdgeData

func (g *Graph) SetEdgeData(source, target, key, value string) error

func (*Graph) SetNodeData

func (g *Graph) SetNodeData(id, key, value string) error

func (*Graph) ToGraphML

func (g *Graph) ToGraphML() ([]byte, error)

type GraphContent

type GraphContent struct {
	Edges       []*Edge `xml:"edge"`
	Nodes       []*Node `xml:"node"`
	Edgedefault string  `xml:"edgedefault,attr"`
}

type GraphMLStruct

type GraphMLStruct struct {
	XMLName xml.Name     `xml:"graphml"`
	Keys    []Key        `xml:"key"`
	Graph   GraphContent `xml:"graph"`
}

type Key

type Key struct {
	ID       string `xml:"id,attr"`
	For      string `xml:"for,attr"`
	AttrName string `xml:"attr.name,attr"`
	AttrType string `xml:"attr.type,attr"`
}

type Node

type Node struct {
	ID   string `xml:"id,attr"`
	Data Data   `xml:"data"`
}

Jump to

Keyboard shortcuts

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