Skip to content

Understanding Page and Block Relations in LogSeq (Part 3)

- 5 min read

In Part 2, we explored how to query basic relation types using advanced queries in LogSeq. This continuation delves into weighting these different types of relations.

Important Notes

During the development of the weighting system, I discovered several defects in the previous relationship listings. While I attempted to use new notation and Mermaid diagrams to cover all cases, this proved to be time-consuming. I’ve decided to focus on the main content for now, with updates to Parts 1 and 2, including new notations and diagrams, coming in the future.

First-Degree Relations

First-degree relations represent direct connections between elements in LogSeq. The new notation system is structured as follows:

Notation Format: {node} {relation}

  • Node: ‘P’ for page, ‘B’ for block
  • Relation: Indicates the relation type, where the second letter indicates the destination element type
  • Example: P MP means a page has a reference to another page in metadata

First-degree relations include:

  • P MP: Page references another page in metadata
    flowchart LR
    subgraph 1P[Page 1]
    1Pp[tags:: page-2]
    end
    1P~~~1P2([&Page 2])
  • P UP: Page belongs to a parent page
    graph LR;
    1P["Page 2 (parent)"]-->1C["Page 1 (child)"];
  • P DP: Page has a child page
    graph LR;
    1P["Page 1 (parent)"]-->1C["Page 2 (child)"];
  • P PB: Page has a block
    graph LR
    subgraph 1P[Page 1]
    1Pb[Block 1]
    end
  • B CP: Block references a page in content
    flowchart LR
    subgraph 1B[Block 1]
    1Bp[#page-1]
    end
    1B~~~2P([&Page 1])
  • B CB: Block references another block in content
    flowchart LR
    subgraph 1B[Block 1]
    1Bb[#block-2]
    end
    1B~~~1B2([&Block 2])
  • B UB: Block belongs to a parent block
    graph LR;
    1P["Block 2 (parent)"]-->1C["Block 1 (child)"];
  • B DB: Block has a child block
    graph LR;
    1P["Block 1 (parent)"]-->1C["Block 2 (child)"];
  • B BP: Block belongs to a page
    graph LR
    subgraph 1P[Page 1]
    1Pb[Block 1]
    end

Second-Degree Relations

Second-degree relations represent indirect connections derived from combining two first-degree relations.

Notation Format: {link type}{node} {1st relation} {2nd relation}

  • Link Type:
    • ’~’ for serial (order-dependent)
    • ’=’ for parallel (order-independent)
  • Example: =P MP MP represents a page with two interrelated page references in metadata

Categories of second-degree relations:

  • OIR: Order Interchangeable Refs
    • =P MP MP
    • =B CP CP
    • =B CP CB
    • =B CB CB
  • DBE: Dereference a block then extend
    • ~B CB BP
    • ~B CB CP
    • ~B CB CB
    • ~B CB UB
    • ~B CB DB
  • BDP: Start from block, dereference a page then extend
    • ~B CP BP
    • ~B CP MP
    • ~B CP DP
    • ~B CP PB
  • PDP: Start from page, dereference a page then extend
    • ~P MP UP
    • ~P MP DP
    • ~P MP MP
    • ~P MP PB
  • 1BB: A block lineal relation + a block ref
    • ~P PB CB
    • =B CB DB
    • =B CB UB
  • 1BP: A block lineal relation + a page ref
    • ~P PB CP
    • =B CP DB
    • =B CP UB
  • 1PP: A page lineal relation + a page ref
    • ~P UP MP
    • =P UP MP
    • =P PB MP
  • 2LD1: Two lineal relations of same node-type with depth of 1
    • =P DP DP
    • =B DB DB
  • 2LD2: Two lineal relations of same node-type with depth of 2
    • ~P UP UP
    • ~B UB UB
  • 2LPB: Two lineal relations of different node-type
    • ~P DP PB
    • ~P UP PB

Methodology and Research Notes

The evaluation methodology combines quantitative and qualitative factors:

  1. Primary Factors (Scale 1-3):

    • Usage frequency (quantitative, based on personal usage data)
    • Dereference complexity (qualitative, the less the better)
  2. Secondary Factors (Scale 1-5):

    • Relation specificity (quantitative, based on maintenance cost)
    • Lineal relation (qualitative, prefer parent relation type)

The final evaluation score uses the formula: primary^3 * secondary^1 to appropriately weight the factors while preventing edge cases where high secondary scores might overshadow primary importance.

Evaluation Result

noitemgroupprimarysecondaryevalrank
1=P MP MPOIR341081
2=B CP CPOIR23245
3=B CP CBOIR221610
4=B CB CBOIR21813
5~B CB BPDBE15517
6~B CB CPDBE14418
7~B CB CBDBE13320
8~B CB UBDBE12222
9~B CB DBDBE11127
10~B CP BPBDP14419
11~B CP MPBDP13321
12~B CP DPBDP12223
13~B CP PBBDP11128
14~P MP UPPDP24323
15~P MP DPPDP23246
16~P MP MPPDP221611
17~P MP PBPDP21814
18~P PB CB1BB23247
19=B CB DB1BB12224
20=B CB UB1BB11129
21~P PB CP1BP23248
22=B CP DB1BP12225
23=B CP UB1BP11130
24~P UP MP1PP23249
25=P UP MP1PP221612
26=P PB MP1PP11131
27=P DP DP2LD131274
28=B DB DB2LD121815
29~P UP UP2LD232542
30~B UB UB2LD221816
31~P DP PB2LPB12226
32~P UP PB2LPB11132

Sorted by rank

noitemgroupprimarysecondaryevalrank
1=P MP MPOIR341081
29~P UP UP2LD232542
14~P MP UPPDP24323
27=P DP DP2LD131274
2=B CP CPOIR23245
15~P MP DPPDP23246
18~P PB CB1BB23247
21~P PB CP1BP23248
24~P UP MP1PP23249
3=B CP CBOIR221610
16~P MP MPPDP221611
25=P UP MP1PP221612
4=B CB CBOIR21813
17~P MP PBPDP21814
28=B DB DB2LD121815
30~B UB UB2LD221816
5~B CB BPDBE15517
6~B CB CPDBE14418
10~B CP BPBDP14419
7~B CB CBDBE13320
11~B CP MPBDP13321
8~B CB UBDBE12222
12~B CP DPBDP12223
19=B CB DB1BB12224
22=B CP DB1BP12225
31~P DP PB2LPB12226
9~B CB DBDBE11127
13~B CP PBBDP11128
20=B CB UB1BB11129
23=B CP UB1BP11130
26=P PB MP1PP11131
32~P UP PB2LPB11132

Conclusion

This research establishes a foundational framework for evaluating second-degree relationships in LogSeq, offering several key contributions:

  1. A quantitative baseline for determining correlations between second-degree relationships, enabling more efficient discovery of indirectly related topics
  2. A unified, succinct notation system for describing complex relationships between pages and blocks, providing a solid foundation for future research
  3. A novel approach to relationship metrics that considers both direct and indirect connections, allowing for more comprehensive topic analysis

These advances open new possibilities for knowledge graph analysis and relationship-based content organization in LogSeq and similar tools.

Research Notes and Methodology Insights

This initial research effort presented several interesting challenges and learning opportunities:

Notation Development

  • The development of a concise notation system emerged as a crucial first step
  • The concepts of “serial” and “parallel” relationships proved valuable, providing geometric equivalents based on directional attributes
  • While the notation is efficient, future work should address additional geometric variants of relationship types

Evaluation Framework Design The evaluation methodology was developed through a systematic approach:

  1. Relationship Grouping

    • Similar relations were clustered to establish coherent categories
    • Secondary factors were evaluated within group contexts (scale 1-5)
    • Primary factors were assessed globally (scale 1-3)
  2. Scoring System

    • Implemented the formula primary^3 * secondary^1
    • This approach successfully prevents edge cases where high secondary scores (e.g., 1 primary, 5 secondary) might inappropriately outweigh more significant relationships (e.g., 2 primary, 1 secondary)
    • Balances quantitative data with qualitative insights

Future Research Directions

  • Incorporate additional academic references to strengthen the theoretical foundation
  • Expand quantitative analysis with formal data collection and validation
  • Explore automated tools for relationship analysis based on this framework
  • Develop standardized metrics for relationship evaluation across different knowledge management systems

This research represents a first step toward a more rigorous understanding of knowledge graph relationships, with significant potential for expansion and refinement in future work.