mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 17:34:57 -05:00
feat(ui): add getNodes method to Graph
This commit is contained in:
@@ -138,6 +138,21 @@ describe('Graph', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNodes', () => {
|
||||
it('should return all nodes in the graph', () => {
|
||||
const g = new Graph();
|
||||
const n1 = g.addNode({
|
||||
id: 'n1',
|
||||
type: 'add',
|
||||
});
|
||||
const n2 = g.addNode({
|
||||
id: 'n2',
|
||||
type: 'sub',
|
||||
});
|
||||
expect(g.getNodes()).toEqual([n1, n2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addEdge', () => {
|
||||
const add: Invocation<'add'> = {
|
||||
id: 'from-node',
|
||||
|
||||
@@ -128,6 +128,14 @@ export class Graph {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all nodes in the graph.
|
||||
* @returns An array of all nodes in the graph.
|
||||
*/
|
||||
getNodes(): AnyInvocation[] {
|
||||
return Object.values(this._graph.nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the immediate incomers of a node.
|
||||
* @param node The node to get the incomers of.
|
||||
|
||||
Reference in New Issue
Block a user