File size: 1,345 Bytes
c1a1d02
2d72d5a
af53b62
2d72d5a
 
af53b62
c1a1d02
 
 
 
2d72d5a
 
 
af53b62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d72d5a
 
 
 
 
c1a1d02
 
 
2d72d5a
 
c1a1d02
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script lang="ts">
  import { onMount } from 'svelte';
  import { type NodeProps } from '@xyflow/svelte';
  import Sigma from 'sigma';
  import * as graphology from 'graphology';
  import * as graphologyLibrary from 'graphology-library';
  import LynxKiteNode from './LynxKiteNode.svelte';
  type $$Props = NodeProps;
  export let id: $$Props['id'];
  export let data: $$Props['data'];
  let sigmaCanvas: HTMLElement;
  let sigmaInstance: Sigma;

  const graph = graphology.Graph.from({
    attributes: {
      name: 'My Graph'
    },
    options: {
      allowSelfLoops: true,
      multi: false,
      type: 'mixed'
    },
    nodes: [
      {key: 'Thomas'},
      {key: 'Eric'}
    ],
    edges: [
      {
        key: 'T->E',
        source: 'Thomas',
        target: 'Eric',
      }
    ]
  });
  graphologyLibrary.layout.random.assign(graph);
  const settings = graphologyLibrary.layoutForceAtlas2.inferSettings(graph);
  graphologyLibrary.layoutForceAtlas2.assign(graph, { iterations: 10, settings });
  graphologyLibrary.layoutNoverlap.assign(graph, { settings: { ratio: 3 } });

  onMount(async () => {
    sigmaInstance = new Sigma(graph, sigmaCanvas);
  });

</script>

<LynxKiteNode id={id} data={data} {...$$restProps}>
  <div bind:this={sigmaCanvas} style="height: 200px; width: 200px;" >
  </div>
</LynxKiteNode>
<style>
</style>