Custom array (a variations on adjacency matrix for graphs)

Hi,

So I am doing a project in which i need to heavily use a graph structure. I have tried several graph package in the past, but they are not flexible enough for my use case. So I started to wonder if the following is possible in an array like structure. Because most of the headache with these graph packages is that they come with overhead and very specific use cases in mind.

So this is what I would want it to look like(see pic). The idea is that instead of trying to add Meta data into a graph package. I add the Metadata directly in a specially developed array. So in this example the first element of the tuple shows the connection between nodes very similar to an adjacency matrix. the second element shows metadata concerning the edge (either ‘1’ or ‘0’ if there is an edge otherwise Nothing). This is very similar to the concept of edge weights but these aren’t weights in this case but Characters, could be a string in another use case for instance.

I know I can do the above part in an array. But here is the unknown/tricky part for me, I would also like the column and row headers to refer directly to their header. So if bellow array is named g. I could write:

>g['J',"Node_3"]  
(1,1)

Is it possible to adjust an array so It accepts that?

image

best,

Maybe you need something like NamedArrays.jl?

Well if you put it like that it seems obvious ;).

I have read briefly through the documentation. Not sure If I can use it same issue arises for example in the document it states:

These constructors add default names to the array of type String, "1" , "2" , … for each dimension, and names the dimensions :A , :B , … (which will be all right for 26 dimensions to start with; 26 dimensions should be enough for anyone:-).

I have 53 elements and due to the nature of the compression algo I will probably end up with 70.

but I will dive deeper and see what can be found. The back-up plan is to make a seperate array that acts as a key so ‘j’ => 1, “Node_3” => 7, etc. at the time I found it an inelegant solution but from a different perspective it will give me way more flexibility also for future graph related projects.

best,