0

So, I'm completely new to graph and gremlin API so I hope someone here can point me in the right direction.

I`m planning to create a overview map of all events during a FPS game. This means I have a list of players, rounds, and all events that have occured in each round. An event could be;

  • Player 1 -> Shot (additional properties like weapon, damage amount, etc would be required) -> Player 2
  • Player 2 -> Killed -> Player 3

and so on...

I'm not quite sure in which way this should be structured. Should the event just be an edge, pointing to the other player (vertex)? This means that the edges need additional properties, and needs to be related to the game round, not sure if this is possible..?

Any help would be much appriciated.

To give a bit more details, this is a typical event.

{
    "attackId": 587204688,
    "attacker": {
        "name": "Danielsol13",
        "teamId": 10,
        "health": 56.031158447265625,
        "location": {
            "x": 218720.15625,
            "y": 467373.53125,
            "z": 13599.349609375
        },
        "ranking": 0,
        "accountId": "account.46118b5fe1954e97a6af47cb6e9506af",
        "isInBlueZone": false,
        "isInRedZone": false,
        "zone": []
    },
    "victim": {
        "name": "BUTTZN",
        "teamId": 3,
        "health": 45.600002288818359,
        "location": {
            "x": 217836.6875,
            "y": 464758.8125,
            "z": 13499.73046875
        },
        "ranking": 0,
        "accountId": "account.308db6ede78048d1aa372f6ee7b87eed",
        "isInBlueZone": false,
        "isInRedZone": false,
        "zone": []
    },
    "damageTypeCategory": "Damage_Gun",
    "damageReason": "HeadShot",
    "damage": 45.600002288818359,
    "damageCauserName": "WeapHK416_C",
    "isThroughPenetrableWall": false,
    "common": {
        "isGame": 1.5
    },
    "_D": "2021-03-15T20:46:24.063Z",
    "_T": "LogPlayerTakeDamage"
}
ffffff01
  • 5,068
  • 11
  • 52
  • 61

1 Answers1

1

The main question you need to ask yourself to decide whether the Event is a vertex or an edge is: Will the event need to connect to any vertices other than the From player vertex and the To player vertex?

You are saying that the Event will need to be connected to a Round. So probably the Event will need to be a vertex. Unless you will never need to use this relationship in your traversals.

If you will never need to traverse this relationship between the Round and the Event, then you can just have a scalar property "RoundId" on the Event edge.

But if you will need to write traversals like "Filter Rounds based on a predicate and then traverse to the round events", then you probably need the event to be a vertex.

Also if you expect that you will write a lot of traversals that start from the Events, like g.V().has('event', ...) or g.E().has('event', ...) then probably you will want events to be vertices, not edges. Because I believe (and I am not 100% certain about this one) that, in most graph databases, searching vertices is more efficient than searching edges.

Bassem
  • 2,736
  • 31
  • 13
  • Thanks alot for your insights @Bassem! I ended up with letting the events be edges for now with an ID for which round they relate to, and players as vertecies. I will see how this turns out, and if the performance is satisfying. – ffffff01 Apr 05 '21 at 12:59