-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graph Issues #166
Comments
Current API: interface DependencyGraph<T>{
// Map nodes to the set of nodes that they depend on.
// Namely, the key is the effect and the value is the set of its origins
adjacencyMap: Map<T, Set<T>>;
// Merge two dependency graphs;
merge: (apg: DependencyGraph<T>) => void;
// Add a node T
addNode: (node: T) => void;
// Given a `node` T denoting effect, return a set of its origins
// TODO1: change the name, `getOrigins` maybe?
// This is best achieved with a dependency graph. Called 6 times in reactor.ts
getEdges: (node: T) => Set<T>;
// Given a `node` denoting origin, return a set of its effects
// TODO1: We MUST rename because "back edge" is very confusing and has a different meaning in graph theory.
// This is best achieved with a precedence graph. Called 4 times in reactor.ts
getBackEdges: (node: T) => Set<T>;
// Return the subset of origins that are reachable from the given effect.
// We should change the signature. presence of `origins` is confusing. It appears that it is effectively taking intersection with the actual reachable vertices.
// Best achieved with a precedence graph. Never called anywhere.
// Maybe change the recursion to be iteration.
reachableOrigins: (effect: T, origins: Set<T>) => Set<T>;
// Return if the graph has cycle.
// Only called in Reactor::canConnect()
hasCycle: () => boolean;
// Remove a node and all associated origin/effect relationship with it.
// Should be the same with precedence graph or dependency graph, as if we don't implement both it's gonna traverse the whole graph either way.
// Only called in Reactor::_deleteConnections()
removeNode: (node: T) => void;
// The following 3 doesn't relate too much with the polarity as one can just invert the arguments
// Add an edge that denotes node->dependson; `dependsOn` is the origin and `node` effect
addEdge: (node: T, dependsOn: T) => void;
// Never called
// TODO: Change name. Reason idem.
addBackEdges: (node: T, dependentNodes: Set<T>) => void;
// Called once in Reactor::_recordDeps()
// Can refactor it to just call `addEdge` multiple times
addEdges: (node: T, dependsOn: Set<T>) => void;
// Remove node->dependsOn edge
// Called two times in reactor.ts
removeEdge: (node: T, dependsOn: T) => void;
// Returns [|V|, |E|], never used
size: () => [number, number];
nodes: () => IterableIterator<T>;
// Returns the DOT representation of the graph. Currently it is a dependency graph,
// but cognitively it might be better to invert the polarity of the graph and make it a precedence graph?
toString: () => string;
// Return a set of verticies that are root in the **precedence** graph,
// i.e. leaf in the **dependency** graph,
// i.e. that does not affect on others, i.e. that are not effects and purely origins.
// Maybe rename it to "pureOriginNodes"? Very confusing
// Never used
rootNodes: () => Set<T>;
// Return a set of verticies that are leaf in the **precedence** graph,
// i.e. root in the **dependency** graph,
// i.e. that does not depend on others, i.e. that are not origins and purely effects.
// Maybe rename it, very confusing
// Used once in `_analyzeDependencies` to collapse the graph.
leafNodes: () => Set<T>;
} Understand all current uses of the graph
Understand whether changing the polarity will have algorithmic disadvantages Come up with an API that we like
Stick to clear terminology across the code base Some other questions:
|
Refactor graph package (addresses #166)
Currently, we encode dependencies using a dependency graph. We are considering inverting the polarity of the edges, effectively turning it into a precedence graph. Before going ahead with this, we need to:
mermaid.js
The text was updated successfully, but these errors were encountered: