Triple Edge is an Edge type that expresses relationships and attributes in the form (Subject, Property, Object).

Dual Mode Design

  • Basic mode (4 words): PropCode 0~62 (Top 63 properties)
  • Extended mode (5 words): When PropCode=63, covers all P-IDs (semantic-aligned 16-bit)

Basic Mode (4 words = 64 bits)

1st WORD (16 bits)
┌────────────────────┬────────────────────┐
│      Prefix        │     PropCode       │
│      10bit         │       6bit         │
└────────────────────┴────────────────────┘

2nd WORD: Edge TID (16 bits)
3rd WORD: Subject TID (16 bits)
4th WORD: Object TID (16 bits)
FieldBitsDescription
Prefix101100 000 001
PropCode60~62: Top 63 properties, 63: extended mode
Edge TID16TID of this Edge
Subject TID16Subject Entity/Node TID
Object TID16Object Entity/Node/Quantity TID

Extended Mode (5 words = 80 bits)

When PropCode is 63, a 16-bit P-ID is added in the 3rd word.

1st WORD: [Prefix 10bit] + [PropCode=63 6bit]
2nd WORD: Edge TID (16 bits)
3rd WORD: P-ID semantic-aligned (16 bits)
4th WORD: Subject TID (16 bits)
5th WORD: Object TID (16 bits)

Top 63 Properties (PropCode 0~62)

Properties selected based on Wikidata usage frequency.

Classification/Type (Code 0~7)

CodeP-IDPropertyDescription
0P31instance ofInstance of ~
1P279subclass ofSubclass of ~
2P361part ofPart of ~
3P527has partContains ~
4P1552has qualityAttribute/characteristic
5P460same asIdentical
6P1889different fromDifferent
7P156followed bySuccessor

Spatial/Location (Code 8~15)

CodeP-IDPropertyDescription
8P17countryCountry
9P131located inLocation (administrative)
10P276locationLocation (place)
11P625coordinateCoordinates
12P30continentContinent
13P36capitalCapital
14P150containsContains (region)
15P206located next toAdjacent body of water

Time (Code 16~23)

CodeP-IDPropertyDescription
16P569date of birthDate of birth
17P570date of deathDate of death
18P571inceptionDate of establishment
19P576dissolvedDate of dissolution
20P577publication datePublication date
21P580start timeStart time
22P582end timeEnd time
23P585point in timePoint in time

Person Basics (Code 24~31)

CodeP-IDPropertyDescription
24P19place of birthPlace of birth
25P20place of deathPlace of death
26P21sex or genderSex or gender
27P27citizenshipCitizenship
28P735given nameGiven name
29P734family nameFamily name
30P1559name in native languageName in native language
31P742pseudonymPseudonym/stage name

Relationships/Affiliation (Code 32~39)

CodeP-IDPropertyDescription
32P22fatherFather
33P25motherMother
34P26spouseSpouse
35P40childChild
36P3373siblingSibling
37P463member ofMember of
38P108employerEmployer
39P1027conferred byConferring institution

Occupation/Activity (Code 40~47)

CodeP-IDPropertyDescription
40P106occupationOccupation
41P39position heldPosition held
42P69educated atEducated at
43P101field of workField of work
44P1344participant inParticipated in (event)
45P166award receivedAward received
46P800notable workNotable work
47P1412languages spokenLanguages spoken

Media/Identification (Code 48~55)

CodeP-IDPropertyDescription
48P18imageImage
49P154logoLogo
50P41flag imageFlag/banner
51P373Commons categoryWikimedia Commons
52P856official websiteOfficial website
53P214VIAF IDVIAF
54P227GND IDGND
55P213ISNIISNI

Works/Creative (Code 56~62)

CodeP-IDPropertyDescription
56P50authorAuthor
57P57directorDirector
58P86composerComposer
59P175performerPerformer/singer
60P136genreGenre
61P364original languageOriginal language
62P123publisherPublisher

Code 63 is reserved as the extended mode indicator.

PropCode Summary

┌─────────────────────────────────────────────┐
│  0~7:   Classification/Type (P31, P279, ...)│
│  8~15:  Spatial/Location (P17, P131, ...)   │
│  16~23: Time (P569, P570, ...)              │
│  24~31: Person Basics (P19, P20, ...)       │
│  32~39: Relationships/Affiliation (P22, ...) │
│  40~47: Occupation/Activity (P106, P39, ...)│
│  48~55: Media/Identification (P18, P856, ...)│
│  56~62: Works/Creative (P50, P57, ...)      │
├─────────────────────────────────────────────┤
│  63: Extended mode indicator                │
└─────────────────────────────────────────────┘

Examples

Basic mode: “Apple is a company”

P31 (instance of) → PropCode = 0

Triple Edge:
  1st: [1100 000 001] + [000000]  - Prefix + PropCode 0
  2nd: [TID: 0x0101]              - Edge TID
  3rd: [TID: 0x0010]              - Apple (Subject)
  4th: [TID: 0x0020]              - Company (Object)

Total: 4 words

Extended mode: “The Eiffel Tower is 330m tall”

P2048 (height) → Not in Top 63 → Extended mode

Triple Edge:
  1st: [1100 000 001] + [111111]  - Prefix + Ext(63)
  2nd: [TID: 0x0102]              - Edge TID
  3rd: [0xA800]                   - P2048 semantic-aligned
  4th: [TID: 0x0030]              - Eiffel Tower (Subject)
  5th: [TID: 0x0050]              - 330m Quantity (Object)

Total: 5 words

Parsing

def parse_triple_edge(data: bytes) -> dict:
    word1 = int.from_bytes(data[0:2], 'big')

    prefix = word1 >> 6
    assert prefix == 0b1100000001, "Not Triple Edge"

    prop_code = word1 & 0x3F

    if prop_code < 63:
        # Basic mode (4 words)
        return {
            'mode': 'basic',
            'prop_code': prop_code,
            'edge_tid': int.from_bytes(data[2:4], 'big'),
            'subject_tid': int.from_bytes(data[4:6], 'big'),
            'object_tid': int.from_bytes(data[6:8], 'big'),
            'words': 4
        }
    else:
        # Extended mode (5 words)
        return {
            'mode': 'extended',
            'p_id': int.from_bytes(data[4:6], 'big'),
            'edge_tid': int.from_bytes(data[2:4], 'big'),
            'subject_tid': int.from_bytes(data[6:8], 'big'),
            'object_tid': int.from_bytes(data[8:10], 'big'),
            'words': 5
        }