Skip graphs support the basic operations of
search,
insert and
delete. Skip graphs will also support the more complex
range search operation.
Search The
search algorithm for skip graphs is almost identical to the search algorithm for skip lists but it is modified to run in a distributed system. Searches start at the top level and traverse through the structure. At each level, the search traverses the list until the next node contains a greater key. When a greater key is found, the search drops to the next level, continuing until the key is found or it is determined that the key is not contained in the set of nodes. If the key is not contained in the set of nodes the largest value less than the search key is returned. Each node in a list has the following fields: ; :The node's value. ; :An array containing pointers to the right and left neighbor in the node's doubly linked at level i. search(searchOp, startNode, searchKey, level)
if (v.key = searchKey)
then send(foundOp, v) to startNode
if (v.key O\left(\frac{\log n}{\log(1/p)}\right) levels for a fixed value of . Given that at most \frac{1}{1-p} nodes are searched on average per level, the total expected number of messages sent is O\left(\frac{\log n}{(1-p)\log(1-p)}\right) and the expected time for the search is O\left(\frac{\log n}{(1-p)\log(1-p)}\right). Therefore, for a fixed value of , the search operation is expected to take time using messages.
Insert Insertion is done in two phases and requires that a new node knows some introducing node ; the introducing node may be any other node currently in the skip graph. In the first phase the new node uses the introducing node to search for its own key; this search is expected to fail and return the node with the largest key smaller than . In the second phase inserts itself in each level until it is the only element in a list at the top level. Insertion at each level is performed using standard doubly linked list operations; the left neighbor's next pointer is changed to point to the new node and the right neighbor's previous pointer is changed to point to the node. insert() search for = 0
while true insert into level L from Scan through level to find such which has membership vector matching membership vector of for first +1 characters
if no exists exit
else = = + 1 Similar to the search, the insert operation takes expected
O(log
n) messages and
O(log
n) time. With a fixed value of p; the search operation in phase 1 is expected to take
O(log
n) time and messages. In phase 2 at each level
L ≥ 0, communicates with an average 1/
p other nodes to locate ', this will require
O(1/
p) time and messages leading to
O(1) time and messages for each step in phase 2.
Delete Nodes may be deleted in parallel at each level in
O(1) time and
O(log
n) messages. When a node wishes to leave the graph it must send messages to its immediate neighbors to rearrange their next and previous pointers. delete()
for L = 1 to max level, in parallel
delete u from each level.
delete u from level 0 The skip graph contains an average of
O(log
n) levels; at each level
u must send 2 messages to complete a delete operation on a doubly linked list. As operations on each level may be done in parallel the delete operation may be finished using
O(1) time and expected
O(log
n) messages. ==Fault tolerance==