Skip to content

Add support for labelled edges #3

@Smuzzy-waiii

Description

@Smuzzy-waiii

Currently the graph has unlabelled edges. The task is to add support for labelled edges.

The way the edges are currently stored as KV pairs in badger are as follows:
The src node is the key and the value is a list of destination nodes which are stored as map[string]bool in the codebase where the string is the dest node and the bool does not really mean anything. This map[string]bool is serialized to []byte using gob and is Set as the Value in badger. Please refer to the Internals section of the CONTRIBUTING.md for more details on how the internal storage representation works

Modify this to use map[string]map[string]bool where the first string is the label and the map[string]bool succeeding it is the same as before.

The following functions will also need to be modified to account for labels: AddEdge, RemoveEdge, GetEdges, OutEdges, IterAllEdges and basically any other function that got added in the course of hacknight itself except maybe for PickRandomVertex

Have GetEdges, OutEdges and IterAllEdges take in a label and allow support for passing in "" as the wildcard operator to operate on all edges. Consequently you will have to modify AddEdge and RemoveEdge to disallow "" being passed as a label.

Please update the function calls lib_test.go file since you are making breaking changes to the API and write unit tests for testing Labelled Edges

psst, remember to update the usage guide in the README too 👀

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions