constant.ts


Overview

The constant.ts file defines and exports a static graph data structure representing entities and their relationships related to a company named "厦门象屿" (Xiamen Xiangyu) and associated events, persons, and geographical locations from 2018 to 2022. This graph data includes nodes (entities) and edges (relationships) with descriptive metadata primarily in Chinese and some English.

This data is structured for use in graph visualization, analysis, or as a knowledge graph within a larger system focusing on company financial metrics, organizational structure, and historical events over time.


File Contents and Structure

The file contains three main parts:

  1. Nodes Array: A list of entity objects representing organizations, events, persons, and geographical locations.

  2. Edges Array: A list of relationships connecting these entities with descriptive context.

  3. Exported Graph Object: An object graphData aggregating the nodes and edges with additional graph metadata.


Detailed Explanation

Nodes Array

Implementation Note:
The initial array assigns a type field as string with extra double quotes (e.g., '"ORGANIZATION"'). The .map(({ type, ...x }) => ({ ...x })) call removes the type property from each node, effectively stripping it out in the final exported nodes array. This suggests the type property is not needed downstream or is managed separately.

Example Node:

{
  id: '"厦门象屿"',
  description: '"厦门象屿是一家公司,其营业收入和市场占有率在2018年至2022年间有所变化。"'
  source_id: '0',
  // `type` is removed after map operation
}

Edges Array

Example Edge:

{
  source: '"厦门象屿"',
  target: '"2018"',
  weight: 2.0,
  description: '"厦门象屿在2018年的营业收入和市场占有率被记录。"'
}

Exported Graph Object

export const graphData = {
  directed: false,
  multigraph: false,
  graph: {},
  nodes,
  edges,
  combos: [],
};

Usage Examples

This file exports graphData which can be imported and used in the following ways:

Example 1: Import and visualize graph

import { graphData } from './constant';

// Use graphData with a graph visualization library such as G6, Cytoscape, or D3
renderGraph(graphData);

Example 2: Query relationships

import { graphData } from './constant';

const nodes = graphData.nodes;
const edges = graphData.edges;

// Find all nodes related to "厦门象屿"
const relatedEdges = edges.filter(
  edge => edge.source === '"厦门象屿"' || edge.target === '"厦门象屿"'
);

console.log(relatedEdges);

Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram: Graph Structure Flowchart

This flowchart represents the main entities (nodes) and their relationships (edges) focusing on key entity groups: Organization, Event, Person, and Geography.

flowchart LR
  subgraph Organizations
    O1["厦门象屿"]
    O2["厦门象屿股份有限公司"]
  end

  subgraph Events
    E2018["2018"]
    E2019["2019"]
    E2020["2020"]
    E2021["2021"]
    E2022["2022"]
    E2021y["2021年"]
    E2022y["2022年"]
    EF["主要财务指标"]
  end

  subgraph Persons
    P1["邓启东"]
    P2["廖杰"]
    P3["史经洋"]
  end

  subgraph Geography
    G1["厦门"]
    G2["厦门市湖里区自由贸易试验区厦门片区"]
    G3["象屿集团大厦"]
  end

  %% Edges: Organizations to Events
  O1 --> E2018
  O1 --> E2019
  O1 --> E2020
  O1 --> E2021
  O1 --> E2022

  %% Organization to Person and Geography
  O2 --> P1
  O2 --> G1

  %% Persons to Geography
  P2 --> G3
  P2 --> G2
  P3 --> G3
  P3 --> G2

  %% Events interrelations
  E2021y --> E2022y
  E2021y --> EF
  E2022y --> EF

Summary


This documentation provides a complete understanding of the constant.ts file, enabling developers to effectively use and maintain this graph data within their applications.