Talk:SimpleGraph-Excel: Difference between revisions
Jump to navigation
Jump to search
Simon Bruns (talk | contribs) |
|||
| Line 68: | Line 68: | ||
} | } | ||
class | class CellRange { | ||
+String startCell | +String startCell | ||
+String endCell | +String endCell | ||
| Line 79: | Line 79: | ||
} | } | ||
class | class CellReference { | ||
+String address | +String address | ||
+boolean isAbsolute | +boolean isAbsolute | ||
| Line 93: | Line 93: | ||
%% Formula AST Package | %% Formula AST Package | ||
class ASTNode { | class ASTNode { | ||
+String nodeType | +String nodeType | ||
} | } | ||
| Line 104: | Line 103: | ||
class BinaryOperation { | class BinaryOperation { | ||
+String operator | +String operator | ||
} | } | ||
| Line 114: | Line 111: | ||
%% TinkerPop Package | %% TinkerPop Package | ||
class | class GraphProperty { | ||
+String name | +String name | ||
+String value | +String value | ||
} | } | ||
class | class GraphVertex { | ||
+String id | +String id | ||
+String label | +String label | ||
} | } | ||
class | class GraphEdge { | ||
+String id | +String id | ||
+String label | +String label | ||
} | } | ||
class | class EdgeCollection { | ||
} | } | ||
class | class VertexCollection { | ||
} | } | ||
%% Excel Package Relationships | %% Excel Package Relationships | ||
Workbook "1" --> "n" Sheet | Workbook "1" --> "n" Sheet | ||
Sheet "1" --> "n" Row | |||
Sheet "1" --> "n" Row | Sheet "1" --> "n" CellRange | ||
Sheet "1" --> "n" | |||
Row "1" --> "n" Cell | Row "1" --> "n" Cell | ||
Cell "0..1" --> "0..1" Formula | Cell "0..1" --> "0..1" Formula | ||
Cell "0..1" --> "0..1" Comment | Cell "0..1" --> "0..1" Comment | ||
CellRange "1" --> "n" Cell | |||
Formula "1" --> "n" | Formula "1" --> "n" CellReference | ||
%% Formula AST Relationships | %% Formula AST Relationships | ||
| Line 150: | Line 146: | ||
ASTNode <|-- BinaryOperation | ASTNode <|-- BinaryOperation | ||
ASTNode <|-- LiteralValue | ASTNode <|-- LiteralValue | ||
ASTNode <|-- | ASTNode <|-- CellReference | ||
FunctionCall "1" --> "n" ASTNode | FunctionCall "1" --> "n" ASTNode | ||
BinaryOperation "1" --> " | BinaryOperation "1" --> "2" ASTNode | ||
Formula "1" --> "1" ASTNode | |||
Formula "1" --> "1" ASTNode | |||
%% TinkerPop Relationships | %% TinkerPop Relationships | ||
GraphEdge --> "1" GraphVertex : in | |||
GraphEdge --> "1" GraphVertex : out | |||
GraphVertex --> "n" GraphProperty | |||
GraphEdge --> "n" GraphProperty | |||
EdgeCollection --> "n" GraphEdge | |||
VertexCollection --> "n" GraphVertex | |||
</mermaid> | </mermaid> | ||
Revision as of 10:47, 27 January 2026
Mental Model
Mapping rules
- Each Vertex type (by label) is converted to an Excel sheet
- Each Edge type (by label) is converted to an Excel sheet
- Each vertex is converted to a row
- Each vertex property is converted to a cell
- Each edge is converted to a row
- Each edge property is converted to a cell
- The header row for Vertices has a column for each property key
- The header for for Edges has a column for each property key + an in and and out column
- The in and out header columns for edges have the label of the corresponding vertex in parentheses
Extended Mapping Rules
Range Mapping
- Ranges can represent collections of vertices or edges
- Named ranges map to specific vertex/edge label types
- Each range spans multiple cells corresponding to multiple graph elements
- Range references in formulas map to graph traversals across multiple vertices/edges
Formula Mapping
- Formulas stored in cells can represent computed properties
- Formula results are mapped to property values in the graph
- Formulas can reference other vertices/edges through cell references
- Complex formulas map to graph traversal expressions
Reference Mapping
- Cell references in formulas map to vertex/edge relationships
- Absolute references ($A$1) map to fixed vertex IDs
- Relative references (A1) map to traversal patterns
- Cross-sheet references map to cross-label relationships between different vertex/edge types
Comment Mapping
- Comments on cells map to metadata properties on vertices/edges
- Comment author maps to a metadata property
- Comment text maps to annotation content
- Comment timestamps preserve temporal information in the graph
Formula AST Mapping
- The Abstract Syntax Tree of formulas maps to graph operations
- FunctionCall nodes map to graph traversal operations:
- SUM() → aggregate property values across connected edges
- VLOOKUP() → vertex lookup by property value
- IF() → conditional edge creation or property assignment
- BinaryOperation nodes map to property computations or edge weights:
- Arithmetic operators (+, -, *, /) → computed properties from multiple vertex properties
- Comparison operators (=, <, >) → edge filtering conditions
- LiteralValue nodes map to constant property values directly stored in the graph
UML diagram
Bidirectional Transformation
Excel to Graph
- Parse workbook structure
- Create vertex types from sheet names (non-edge sheets)
- Create edge types from sheet names (sheets with in/out columns)
- For each row in vertex sheets:
- Create vertex with label = sheet name
- Map each cell to a property
- Evaluate formulas and store results
- Attach comments as metadata properties
- For each row in edge sheets:
- Create edge with label = sheet name
- Resolve in/out references to vertices
- Map remaining cells to edge properties
- Process named ranges as vertex/edge collections
- Build formula AST for computed properties
Graph to Excel
- Create sheet for each unique vertex label
- Create sheet for each unique edge label
- For each vertex:
- Create row in corresponding sheet
- Create cell for each property
- Add comments from metadata properties
- For each edge:
- Create row in corresponding sheet
- Add in/out columns with vertex references
- Create cell for each property
- Create named ranges for logical vertex/edge groupings
- Reconstruct formulas from computed properties with AST
Example Mapping
Graph Example
// Vertices
person1 = g.addV('Person').property('name', 'Alice').property('age', 30).next()
person2 = g.addV('Person').property('name', 'Bob').property('age', 25).next()
company1 = g.addV('Company').property('name', 'TechCorp').property('revenue', 1000000).next()
// Edges
g.addE('WORKS_AT').from(person1).to(company1).property('salary', 75000).next()
g.addE('WORKS_AT').from(person2).to(company1).property('salary', 65000).next()
g.addE('KNOWS').from(person1).to(person2).property('since', 2020).next()
Excel Example
Sheet: Person
| name | age | totalSalary (Formula) |
|---|---|---|
| Alice | 30 | =VLOOKUP(A2,WORKS_AT!A:C,3,FALSE) |
| Bob | 25 | =VLOOKUP(A3,WORKS_AT!A:C,3,FALSE) |
Sheet: Company
| name | revenue | avgEmployeeSalary (Formula) |
|---|---|---|
| TechCorp | 1000000 | =AVERAGE(WORKS_AT!C:C) |
Sheet: WORKS_AT (Edge)
| out (Person) | in (Company) | salary |
|---|---|---|
| Alice | TechCorp | 75000 |
| Bob | TechCorp | 65000 |
Sheet: KNOWS (Edge)
| out (Person) | in (Person) | since |
|---|---|---|
| Alice | Bob | 2020 |
Named Ranges:
- AllEmployees = Person!A2:B3
- CompanyFinancials = Company!A2:C2
- Salaries = WORKS_AT!C2:C3
Comments:
- Cell Person!A2: "CEO of department" (Author: Admin, Date: 2024-01-15)
- Cell Company!B2: "Annual revenue in USD" (Author: Finance, Date: 2024-01-10)
Implementation Notes
- Formula evaluation must handle circular references between sheets
- Cross-sheet references require maintaining vertex/edge ID mappings
- Named ranges improve query performance by pre-defining common traversals
- Comments preserve audit trail and metadata
- AST parsing enables complex graph queries from Excel formulas
- Absolute vs relative references determine query pattern (fixed vs traversal)