+
+
+
+ Network Too Large
+
+ The network you are loading is too large to visualize in this tool. Please select one of the following options:
+
+
+
+
+
Choose a random subset of nodes
+
+
+ subset
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main.ts b/src/main.ts
index c36b180..3e06984 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,5 +1,7 @@
import LoginMenu from './components/LoginMenu.vue';
+import NetworkSubsetter from './components/NetworkSubsetter.vue';
export {
LoginMenu,
+ NetworkSubsetter,
};
\ No newline at end of file
diff --git a/src/types.ts b/src/types.ts
new file mode 100644
index 0000000..a754d1f
--- /dev/null
+++ b/src/types.ts
@@ -0,0 +1,26 @@
+import { TableRow } from 'multinet';
+
+export interface Node extends TableRow {
+ type: string;
+ neighbors: string[];
+ degreeCount: number;
+ children?: Node[];
+ parentPosition?: number;
+ [propName: string]: unknown;
+}
+
+export interface Edge extends TableRow {
+ _from: string;
+ _to: string;
+ [propName: string]: unknown;
+}
+
+export interface Network {
+ nodes: Node[];
+ edges: Edge[];
+}
+
+export interface LoadError {
+ message: string;
+ href: string;
+}
diff --git a/src/utils/queryUtils.ts b/src/utils/queryUtils.ts
new file mode 100644
index 0000000..c078322
--- /dev/null
+++ b/src/utils/queryUtils.ts
@@ -0,0 +1,46 @@
+import { LoadError, Network } from '../types';
+import { multinetApi } from 'multinet';
+
+export async function subsetNetwork(
+ workspaceName: string,
+ subsetAmount: number,
+ nodeTableNames: string[],
+ edgeTableName: string,
+ loadError: LoadError,
+ setLoadError: (a: LoadError) => void,
+ networkName: string,
+ api: ReturnType
+) {
+ const aqlQuery = `let nodes = (FOR n in [${nodeTableNames}][**] LIMIT ${subsetAmount} RETURN n) let edges = (FOR e in ${edgeTableName} filter e._from in nodes[**]._id && e._to in nodes[**]._id RETURN e)
+ RETURN {"nodes": nodes[**], edges}`;
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ let newAQLNetwork: Network = { nodes: [], edges: []};
+
+ try {
+ newAQLNetwork = (await api.aql(workspaceName, { query: aqlQuery, bind_vars: {} }) as Network[])[0];
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ } catch (error: any) {
+ if (error.status === 400) {
+ setLoadError({
+ message: error.statusText,
+ href: 'https://multinet.app',
+ });
+ } else {
+ setLoadError({
+ message: 'An unexpected error ocurred',
+ href: 'https://multinet.app',
+ });
+ }
+ } finally {
+ if (loadError.message === 'The network you are loading is too large' && typeof newAQLNetwork === 'undefined') {
+ // Catches CORS errors, issues when DB/API are down, etc.
+ setLoadError({
+ message: 'There was a network issue when getting data',
+ href: `./?workspace=${workspaceName}&network=${networkName}`,
+ });
+ }
+ }
+
+ return newAQLNetwork;
+}
\ No newline at end of file