go_graph

package module
v0.0.0-...-68c9b76 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

README

go_graph

My little teach myself go project. A simple little graph DB engine written in go.

The thing I want to explore with this project is the goroutines. My plan for this is write a basic graph DB engine that will be able to build the graph structure when given new data. The current plan is to only have graph edge of predifened types (as in you have to create the edge type before you can use it). Then the data nodes will have lists of valid edges that can connect to the node and another list of edges that can connect from the node. The final step in this process is to creat building logic, so I can tell the DB what connection a node of a given type should have.

EG:

node Person a Person has from/to edge type sibling a Person has from edge type child a Person has To edge type Parent a Person has to edge type Aunty a person has From edage type Niece

So I have 3 sisters, when I have a daughter. I only have to tell the DB that I have had a child and the DB engine (in the background using goroutines) will use the give rules for a person to create all the Sibling, Aunt/Niece, Cousin relations automatically

To start with this will be an in memory process only.

Have: Creted data store edge types

Next step(s): UNIT TESTS!!!!!! Put data and edge nodes together use graph node to keep track of all the edges a node has traverse the graph. build logic to automatically create edges for a node (start with static example) make a system to create this logic as needed Write a standard set of graph searches. Make an API so other processes can use this graph engine Rewrite everything again from scratch using what I have larnt along the way

This DB can only run on 1 machine (add culstering? how?)

Everything is held in memory no permiant store (What file format works for a graph?)

Documentation

Overview

All the helper functions that don't direct functionality for the Graph, but help that functionality along. (Didn't want to call this file lib because that can get really confusing)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEdgeType

func CreateEdgeType(name string, validFrom, validTo []NodeType) (*edgeType, error)

func CreateNewNodeType

func CreateNewNodeType(name, desc string) error

func GetEdgeType

func GetEdgeType(name string) (*edgeType, error)

func GetId

func GetId() []byte

func NodeError

func NodeError(val string) *nodeError

func StartArrayRegExWalkingPath

func StartArrayRegExWalkingPath(edges [][]string, output chan GraphNode, start *GraphNode)

A helper function to start walking a graph. Output is the interfaces concern. Always start on a GraphNode

func StartArrayStringWalkingPath

func StartArrayStringWalkingPath(edges [][]string, output chan GraphNode, start *GraphNode)

A helper function to start walking a graph. Output is the interfaces concern. Always start on a GraphNode

Types

type DataNode

type DataNode struct {
	NodeData           // The data stored at this node
	SetValue sync.Once // The value can only be set once
	// contains filtered or unexported fields
}

func CreateDataNode

func CreateDataNode(t *NodeType, d []byte) (*DataNode, error)

func (*DataNode) GetId

func (dh *DataNode) GetId() string

func (*DataNode) GetType

func (dh *DataNode) GetType() *NodeType

func (*DataNode) GetValue

func (dh *DataNode) GetValue() NodeData

type EdgeStep

type EdgeStep struct {
	Edge  GraphEdge
	Edges [][]string
}

type GraphEdge

type GraphEdge struct {
	EdgeType    *edgeType
	ConnectFrom *GraphNode
	ConnectTo   *GraphNode
}

func NewGraphEdge

func NewGraphEdge(edTy string, from, to *GraphNode) (*GraphEdge, error)

Create new edge. An edge is allowed to link to the same node

type GraphNode

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

func NewGraphNode

func NewGraphNode(nt *NodeType, input []byte) (*GraphNode, error)

func (*GraphNode) AddFromEdge

func (gn *GraphNode) AddFromEdge(from *GraphEdge) error

func (*GraphNode) AddToEdge

func (gn *GraphNode) AddToEdge(to *GraphEdge) error

func (*GraphNode) GetConnectFrom

func (gn *GraphNode) GetConnectFrom() []GraphEdge

func (*GraphNode) GetConnectTo

func (gn *GraphNode) GetConnectTo() []GraphEdge

func (*GraphNode) Init

func (gn *GraphNode) Init(nt *NodeType, input NodeData, from, to *GraphEdge) error

func (*GraphNode) SetValue

func (gn *GraphNode) SetValue(input NodeData) error

Set the value this GraphNode stores. Can be called many times but onyl sets a value the first time it has been called.

func (*GraphNode) Value

func (gn *GraphNode) Value() NodeData

returns the value that the GraphNode has

type NodeData

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

func (*NodeData) GetData

func (nd *NodeData) GetData() []byte

type NodeStep

type NodeStep struct {
	Node  GraphNode
	Edges [][]string
}

type NodeType

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

func GetNodeType

func GetNodeType(name string) (*NodeType, error)

func GetOrCreateNodeType

func GetOrCreateNodeType(name, desc string) (*NodeType, error)

func TempUnstoredNodeType

func TempUnstoredNodeType(nam, desc string) NodeType

type PathWalker

type PathWalker interface {
	NextStep(node *NodeStep)
	TakeStep(edge *EdgeStep)
	ProcessEdges()
	ProcessNodes()
}

type RelationSet

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

To handle a set of relation eg. Famly would holed brother, sister etc

func (*RelationSet) ValidFromNode

func (rs *RelationSet) ValidFromNode(et *edgeType) (*NodeType, error)

func (*RelationSet) ValidToNode

func (rs *RelationSet) ValidToNode(et *edgeType) (*NodeType, error)

Jump to

Keyboard shortcuts

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