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:
Nodes Array: A list of entity objects representing organizations, events, persons, and geographical locations.
Edges Array: A list of relationships connecting these entities with descriptive context.
Exported Graph Object: An object
graphDataaggregating the nodes and edges with additional graph metadata.
Detailed Explanation
Nodes Array
Each node represents an entity such as a company, event (year), person, or location.
Node properties include:
id(string): Unique identifier, often the name of the entity.type(string): The category of the entity (e.g., "ORGANIZATION", "EVENT", "PERSON", "GEO").description(string): Text describing the entity, mostly in Chinese with some English.source_id(string): An identifier pointing to the source of the information.Optional entity_type duplicates
typein some nodes for clarity or legacy reasons.
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
Each edge represents a relationship between two nodes.
Edge properties include:
source(string):idof the source node.target(string):idof the target node.weight(number): Numeric weight indicating relationship strength, uniformly 2.0 here.description(string): Explains the nature of the relationship.source_id(string): Source identifier matching that of related nodes.
Example Edge:
{
source: '"厦门象屿"',
target: '"2018"',
weight: 2.0,
description: '"厦门象屿在2018年的营业收入和市场占有率被记录。"'
}
Exported Graph Object
export const graphData = {
directed: false,
multigraph: false,
graph: {},
nodes,
edges,
combos: [],
};
directed: false— The graph is undirected; edges have no direction.multigraph: false— Multiple edges between the same nodes are not allowed.graph: {}— Placeholder for graph-level metadata (empty here).nodes— The processed nodes array (withouttypeproperty).edges— The edges array defining relationships.combos: []— Empty array, possibly reserved for grouping nodes (combos) in the visualization framework used.
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
The nodes are defined with an initial
typefield that is removed by a.map()— this suggests thetypemight be used temporarily during data preparation or validation but is not required in the final graph representation.The edges strictly connect nodes by their
idstrings.Weights are uniform, indicating equal strength or importance of all edges.
The graph is undirected, so edges do not imply directionality.
No complex algorithms exist in this file; it serves as a static data definition.
Interaction with Other System Components
This file likely acts as a data source or constant module for graph-based visualizations or analyses within a broader application.
It might interface with:
Graph rendering components (e.g., React components using G6 or D3).
Data querying modules that extract insights from relationships.
Localization modules (since descriptions are bilingual).
The
source_idfields hint at integration with external data sources or provenance tracking systems.The empty
combosarray suggests potential for hierarchical grouping or cluster visualization elsewhere.
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
Purpose: Defines a static knowledge graph dataset representing company-related entities and their relationships over time.
Content: Nodes (entities) and edges (relationships) with descriptions and metadata.
Data Shape: Undirected graph without multi-edges or combos.
Use Case: Visualization, querying, or analysis of company organizational and event data.
Key Entities: Organization "厦门象屿", events from 2018–2022, key persons, and geographic locations.
Design Notes:
typeis stripped from nodes before export, suggesting focus on simplified entity objects.
This documentation provides a complete understanding of the constant.ts file, enabling developers to effectively use and maintain this graph data within their applications.