Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Return the weights of a graph
ResourceFunction["GraphWeights"][g] returns the weights of the edges in graph g. | |
ResourceFunction["GraphWeights"][g,"Edge"] returns the weights of the edges in graph g. | |
ResourceFunction["GraphWeights"][g,"Vertex"] returns the weights of the vertices in graph g. |
Find the weights in a graph:
In[1]:= | ![]() |
Out[1]= | ![]() |
In[2]:= | ![]() |
Out[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
Find the weights of the vertices in a graph:
In[4]:= | ![]() |
Out[4]= | ![]() |
In[5]:= | ![]() |
Out[5]= | ![]() |
Works with undirected weighted graphs:
In[6]:= | ![]() |
Out[6]= | ![]() |
Directed weighted graphs:
In[7]:= | ![]() |
Out[7]= | ![]() |
Weighted Multigraphs:
In[8]:= | ![]() |
Out[8]= | ![]() |
Mixed weighted graphs:
In[9]:= | ![]() |
Out[9]= | ![]() |
We can identify if a graph has negatively weighted edges:
In[10]:= | ![]() |
In[11]:= | ![]() |
Out[11]= | ![]() |
In[12]:= | ![]() |
Out[12]= | ![]() |
If the graph is not weighted it returns weights of value 1:
In[13]:= | ![]() |
Out[13]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License