-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from CorayThan/master
Adding embedded type definition files.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Type definitions for ngraph.graph v0.0.14 | ||
// Project: https://github.com/anvaka/ngraph.graph | ||
// Definitions by: Nathan Westlake <https://github.com/CorayThan> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
declare module "ngraph.graph" { | ||
|
||
type NodeId = string | number | ||
|
||
interface Link { | ||
id: string, | ||
fromId: NodeId, | ||
toId: NodeId, | ||
data: any | ||
} | ||
|
||
interface Node { | ||
id: NodeId, | ||
links: Link[], | ||
data: any | ||
} | ||
|
||
interface Coordinates { | ||
x: number, | ||
y: number | ||
} | ||
|
||
interface Graph { | ||
addNode: (node: NodeId, nodeCoordinates: Coordinates) => Node | ||
addLink: (from: NodeId, to: NodeId, data?: any) => Link | ||
removeLink: (link: Link) => boolean | ||
removeNode: (nodeId: NodeId) => boolean | ||
getNode: (nodeId: NodeId) => Node | undefined | ||
hasNode: (nodeId: NodeId) => Node | undefined | ||
getLink: (fromNodeId: NodeId, toNodeId: NodeId) => Link | null | ||
hasLink: (fromNodeId: NodeId, toNodeId: NodeId) => Link | null | ||
getNodesCount: () => number | ||
getLinksCount: () => number | ||
getLinks: Link[] | ||
forEachNode: (callbackPerNode: (node: Node) => void) => void | ||
forEachLinkedNode: (nodeId: NodeId, callbackPerNode: (node: Node, link: Link) => void, oriented: boolean) => void | ||
forEachLink: (callbackPerLink: (link: Link) => void) => void | ||
beginUpdate: () => void | ||
endUpdate: () => void | ||
clear: () => void | ||
} | ||
|
||
export default function createGraph(options?: { multigraph: boolean }): Graph | ||
|
||
} |