|
|
|
|
|
by Scaevolus
4676 days ago
|
|
An undirected graph is equivalent to a directed graph with doubled edges. The only efficient way to implement an undirected graph is as a directed graph with doubled edges. You want to list friends of Alice. Directed: query all friend(Alice, X). Undirected: query all friend(Alice, X) OR friend(X, Alice). Finding all friend(X, Alice) will be very slow without an index of all friend relationships with Alice in the second position. Storing this is harder than just storing friend(Alice, X) and friend(X, Alice). |
|