You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 👀
The text was updated successfully, but these errors were encountered:
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 thestring
is the dest node and the bool does not really mean anything. Thismap[string]bool
is serialized to[]byte
usinggob
and isSet
as the Value in badger. Please refer to the Internals section of the CONTRIBUTING.md for more details on how the internal storage representation worksModify this to use
map[string]map[string]bool
where the firststring
is the label and themap[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 forPickRandomVertex
Have
GetEdges
,OutEdges
andIterAllEdges
take in a label and allow support for passing in "" as the wildcard operator to operate on all edges. Consequently you will have to modifyAddEdge
andRemoveEdge
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 Edgespsst, remember to update the usage guide in the README too 👀
The text was updated successfully, but these errors were encountered: