Documentation ¶
Index ¶
- type Edge
- func (e Edge) Attributes() []encoding.Attribute
- func (e Edge) Attrs() attrs.Attrs
- func (e Edge) DOTID() string
- func (e *Edge) From() gngraph.Node
- func (e Edge) FromNode(ctx context.Context) (graph.Node, error)
- func (e *Edge) ReversedEdge() gngraph.Edge
- func (e *Edge) SetDOTID(id string)
- func (e *Edge) To() gngraph.Node
- func (e Edge) ToNode(ctx context.Context) (graph.Node, error)
- func (e Edge) UID() uuid.UID
- func (e Edge) Weight() float64
- type Graph
- type Node
- type WUG
- func (g *WUG) AddNode(ctx context.Context, n graph.Node) error
- func (g *WUG) DOT() (string, error)
- func (g *WUG) DOTAttributers() (graph, node, edge encoding.Attributer)
- func (g WUG) DOTID() string
- func (g *WUG) Edge(ctx context.Context, uid, vid uuid.UID) (graph.Edge, error)
- func (g *WUG) Edges(ctx context.Context) ([]graph.Edge, error)
- func (g *WUG) Link(ctx context.Context, from, to uuid.UID, opts ...graph.Option) (graph.Edge, error)
- func (g *WUG) NewNode(ctx context.Context, ent space.Entity, opts ...graph.Option) (graph.Node, error)
- func (g *WUG) Node(ctx context.Context, uid uuid.UID) (graph.Node, error)
- func (g *WUG) Nodes(ctx context.Context) ([]graph.Node, error)
- func (g WUG) Query(ctx context.Context, q query.Query) ([]graph.Object, error)
- func (g *WUG) RemoveLink(ctx context.Context, from, to uuid.UID) error
- func (g *WUG) RemoveNode(ctx context.Context, uid uuid.UID) error
- func (g *WUG) SubGraph(ctx context.Context, uid uuid.UID, depth int, opts ...graph.Option) (graph.Graph, error)
- func (g WUG) UID() uuid.UID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge implements graph.WeightedEdge
func NewEdge ¶
NewEdge creates new Edge and returns it. If no DOTID is given, DOTID returns UID. If both WithUID and WithDOTID are provided DOTID overrides the UID value.
func (Edge) Attributes ¶
Attributes implements store.DOTAttrs
func (*Edge) ReversedEdge ¶
ReversedEdge returns a new edge with end points of the pair swapped.
type Graph ¶
type Graph interface { graph.Graph graph.SubGrapher graph.NodeAdder graph.NodeRemover graph.NodeLinker graph.LinkRemover }
Graph is in-memory graph.
type Node ¶
Node is a graph node.
func NewNode ¶
NewNode creates new Node and returns it. NOTE: if WithAttrs is passed it, its values ovverride Object.Attrs
func (Node) Attributes ¶
Attributes implements attrs.DOT.
type WUG ¶
type WUG struct { *simple.WeightedUndirectedGraph // contains filtered or unexported fields }
WUG is weighted undirected graph.
func NewWUG ¶
NewWUG creates a new weighted undirected graph and returns it. If DOTID is not provided via options, it's set to graph UID>
func (*WUG) DOTAttributers ¶
func (g *WUG) DOTAttributers() (graph, node, edge encoding.Attributer)
DOTAttributers implements encoding.Attributer.
func (*WUG) Link ¶
func (g *WUG) Link(ctx context.Context, from, to uuid.UID, opts ...graph.Option) (graph.Edge, error)
Link creates a new edge between from and to and returns it or it returns the existing edge. It returns error if either of the nodes does not exist in the graph.
func (*WUG) NewNode ¶
func (g *WUG) NewNode(ctx context.Context, ent space.Entity, opts ...graph.Option) (graph.Node, error)
NewNode creates a new graph node and returns it. NOTE: this is a convenience method which creates the new *memory.Node such that it makes sure its ID does not already exist in the graph relieving you from the necessity to make sure your new Node.ID() returns unique ID in the underlying graph.
func (*WUG) Node ¶
Node returns the node with the given ID if it exists in the graph, and error if it could not be retrieved.
func (*WUG) RemoveLink ¶
RemoveLink removes link between two nodes.
func (*WUG) RemoveNode ¶
RemoveNode removes the node with the given id from graph.