graphdb

package
v3.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IN int = iota
	OUT
	BOTH
)

Constant values that represent the direction of edges during graph queries.

Variables

This section is empty.

Functions

This section is empty.

Types

type CayleyGraph

type CayleyGraph struct {
	sync.Mutex
	// contains filtered or unexported fields
}

CayleyGraph is the object for managing a network infrastructure link graph.

func NewCayleyGraph

func NewCayleyGraph(path string) *CayleyGraph

NewCayleyGraph returns an intialized CayleyGraph object.

func NewCayleyGraphMemory

func NewCayleyGraphMemory() *CayleyGraph

NewCayleyGraphMemory creates a temporary graph in memory.

func (*CayleyGraph) AllNodesOfType

func (g *CayleyGraph) AllNodesOfType(ntypes ...string) ([]Node, error)

AllNodesOfType implements the GraphDatabase interface.

func (*CayleyGraph) Close

func (g *CayleyGraph) Close()

Close implements the GraphDatabase interface.

func (*CayleyGraph) CountInEdges

func (g *CayleyGraph) CountInEdges(node Node, predicates ...string) (int, error)

CountInEdges implements the GraphDatabase interface.

func (*CayleyGraph) CountOutEdges

func (g *CayleyGraph) CountOutEdges(node Node, predicates ...string) (int, error)

CountOutEdges implements the GraphDatabase interface.

func (*CayleyGraph) CountProperties

func (g *CayleyGraph) CountProperties(node Node, predicates ...string) (int, error)

CountProperties implements the GraphDatabase interface.

func (*CayleyGraph) DeleteEdge

func (g *CayleyGraph) DeleteEdge(edge *Edge) error

DeleteEdge implements the GraphDatabase interface.

func (*CayleyGraph) DeleteNode

func (g *CayleyGraph) DeleteNode(node Node) error

DeleteNode implements the GraphDatabase interface.

func (*CayleyGraph) DeleteProperty

func (g *CayleyGraph) DeleteProperty(node Node, predicate, value string) error

DeleteProperty implements the GraphDatabase interface.

func (*CayleyGraph) DumpGraph

func (g *CayleyGraph) DumpGraph() string

DumpGraph returns a string containing all data currently in the graph.

func (*CayleyGraph) InsertEdge

func (g *CayleyGraph) InsertEdge(edge *Edge) error

InsertEdge implements the GraphDatabase interface.

func (*CayleyGraph) InsertNode

func (g *CayleyGraph) InsertNode(id, ntype string) (Node, error)

InsertNode implements the GraphDatabase interface.

func (*CayleyGraph) InsertProperty

func (g *CayleyGraph) InsertProperty(node Node, predicate, value string) error

InsertProperty implements the GraphDatabase interface.

func (*CayleyGraph) NodeToID

func (g *CayleyGraph) NodeToID(n Node) string

NodeToID implements the GraphDatabase interface.

func (*CayleyGraph) ReadEdges

func (g *CayleyGraph) ReadEdges(node Node, predicates ...string) ([]*Edge, error)

ReadEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadInEdges

func (g *CayleyGraph) ReadInEdges(node Node, predicates ...string) ([]*Edge, error)

ReadInEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadNode

func (g *CayleyGraph) ReadNode(id, ntype string) (Node, error)

ReadNode implements the GraphDatabase interface.

func (*CayleyGraph) ReadOutEdges

func (g *CayleyGraph) ReadOutEdges(node Node, predicates ...string) ([]*Edge, error)

ReadOutEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadProperties

func (g *CayleyGraph) ReadProperties(node Node, predicates ...string) ([]*Property, error)

ReadProperties implements the GraphDatabase interface.

func (*CayleyGraph) String

func (g *CayleyGraph) String() string

String returns a description for the CayleyGraph object.

type Edge

type Edge struct {
	Predicate string
	From, To  Node
}

Edge represents an edge in the graph.

type GraphDatabase

type GraphDatabase interface {
	fmt.Stringer

	NodeToID(node Node) string
	// Provides all nodes in the graph of the identified types
	AllNodesOfType(ntypes ...string) ([]Node, error)

	// Graph operations for adding and removing nodes
	InsertNode(id, ntype string) (Node, error)
	ReadNode(id, ntype string) (Node, error)
	DeleteNode(node Node) error

	// Graph operations for manipulating properties of a node
	InsertProperty(node Node, predicate, value string) error
	ReadProperties(node Node, predicates ...string) ([]*Property, error)
	CountProperties(node Node, predicates ...string) (int, error)
	DeleteProperty(node Node, predicate, value string) error

	// Graph operations for adding and removing edges
	InsertEdge(edge *Edge) error
	ReadEdges(node Node, predicates ...string) ([]*Edge, error)
	ReadInEdges(node Node, predicates ...string) ([]*Edge, error)
	CountInEdges(node Node, predicates ...string) (int, error)
	ReadOutEdges(node Node, predicates ...string) ([]*Edge, error)
	CountOutEdges(node Node, predicates ...string) (int, error)
	DeleteEdge(edge *Edge) error

	// Signals the database to close
	Close()
}

GraphDatabase is the interface for storage of Amass data.

type Gremlin

type Gremlin struct {
	sync.Mutex
	URL string
	// contains filtered or unexported fields
}

Gremlin is the client object for a Gremlin/TinkerPop graph database connection.

func NewGremlin

func NewGremlin(url, user, pass string) *Gremlin

NewGremlin returns a client object that implements the GraphDatabase interface. The url param typically looks like the following: ws://localhost:8182

func (*Gremlin) AllNodesOfType

func (g *Gremlin) AllNodesOfType(ntypes ...string) ([]Node, error)

AllNodesOfType implements the GraphDatabase interface.

func (*Gremlin) Close

func (g *Gremlin) Close()

Close implements the GraphDatabase interface.

func (*Gremlin) CountInEdges

func (g *Gremlin) CountInEdges(node Node, predicates ...string) (int, error)

CountInEdges implements the GraphDatabase interface.

func (*Gremlin) CountOutEdges

func (g *Gremlin) CountOutEdges(node Node, predicates ...string) (int, error)

CountOutEdges implements the GraphDatabase interface.

func (*Gremlin) CountProperties

func (g *Gremlin) CountProperties(node Node, predicates ...string) (int, error)

CountProperties implements the GraphDatabase interface.

func (*Gremlin) DeleteEdge

func (g *Gremlin) DeleteEdge(edge *Edge) error

DeleteEdge implements the GraphDatabase interface.

func (*Gremlin) DeleteNode

func (g *Gremlin) DeleteNode(node Node) error

DeleteNode implements the GraphDatabase interface.

func (*Gremlin) DeleteProperty

func (g *Gremlin) DeleteProperty(node Node, predicate, value string) error

DeleteProperty implements the GraphDatabase interface.

func (*Gremlin) DumpGraph

func (g *Gremlin) DumpGraph() string

DumpGraph returns a string containing all data currently in the graph.

func (*Gremlin) InsertEdge

func (g *Gremlin) InsertEdge(edge *Edge) error

InsertEdge implements the GraphDatabase interface.

func (*Gremlin) InsertNode

func (g *Gremlin) InsertNode(id, ntype string) (Node, error)

InsertNode implements the GraphDatabase interface.

func (*Gremlin) InsertProperty

func (g *Gremlin) InsertProperty(node Node, predicate, value string) error

InsertProperty implements the GraphDatabase interface.

func (*Gremlin) NodeToID

func (g *Gremlin) NodeToID(n Node) string

NodeToID implements the GraphDatabase interface.

func (*Gremlin) ReadEdges

func (g *Gremlin) ReadEdges(node Node, predicates ...string) ([]*Edge, error)

ReadEdges implements the GraphDatabase interface.

func (*Gremlin) ReadInEdges

func (g *Gremlin) ReadInEdges(node Node, predicates ...string) ([]*Edge, error)

ReadInEdges implements the GraphDatabase interface.

func (*Gremlin) ReadNode

func (g *Gremlin) ReadNode(id, ntype string) (Node, error)

ReadNode implements the GraphDatabase interface.

func (*Gremlin) ReadOutEdges

func (g *Gremlin) ReadOutEdges(node Node, predicates ...string) ([]*Edge, error)

ReadOutEdges implements the GraphDatabase interface.

func (*Gremlin) ReadProperties

func (g *Gremlin) ReadProperties(node Node, predicates ...string) ([]*Property, error)

ReadProperties implements the GraphDatabase interface.

func (*Gremlin) String

func (g *Gremlin) String() string

String returns a description for the Gremlin client object.

type Node

type Node interface{}

Node represents a node in the graph.

type Property

type Property struct {
	Predicate string
	Value     string
}

Property represents a node property.

Jump to

Keyboard shortcuts

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