Skip to main content

Does the following do what you want?

WeightedGraph[edges_, weightsweights_, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->((#[[1]]->0.9*#[[2]]/maxweight)&/@weights),options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

Mathematica graphics

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

Does the following do what you want?

WeightedGraph[edges_, weights, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->((#[[1]]->0.9*#[[2]]/maxweight)&/@weights),options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

Does the following do what you want?

WeightedGraph[edges_, weights_, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->((#[[1]]->0.9*#[[2]]/maxweight)&/@weights),options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

Mathematica graphics

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

fixed a bug
Source Link
celtschk
  • 19.2k
  • 1
  • 51
  • 107

Does the following do what you want?

WeightedGraph[edges_, weights, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->((#[[1]]->0.9*#[[2]]/maxweight)&/@weights),options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

Does the following do what you want?

WeightedGraph[edges_, weights, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->(#[[1]]->0.9*#[[2]]/maxweight)&/@weights,options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

Does the following do what you want?

WeightedGraph[edges_, weights, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->((#[[1]]->0.9*#[[2]]/maxweight)&/@weights),options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.

Source Link
celtschk
  • 19.2k
  • 1
  • 51
  • 107

Does the following do what you want?

WeightedGraph[edges_, weights, options___]:=
  Block[{maxweight=Max[#[[2]]&/@weights]},
    Graph[edges,VertexSize->(#[[1]]->0.9*#[[2]]/maxweight)&/@weights,options]]

WeightedGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
               3 \[UndirectedEdge] 1, 3 \[UndirectedEdge] 4},
   (*weights:*) {1 -> 1.1, 2 -> 1.2, 3 -> 1.3, 4 -> 1.4}]

The second line is basically your Graph call, except that it uses WeightedGraph instead of Graph, and the weights don't have VertexSize-> in front of them.