## plotting – How to mark nodes and insert weights in an adjacency graph?

I have a graph with 12 nodes. The x and y coordinates are give as

``````xcord={154.780094065851,    302.747331652902,   348.235746943268,   959.228504576796,   1021.26721027296,   1114.13365936238,   358.208241883160,   181.741156296042,   838.759299985938,   906.502702816486,   662.579285251179,   536.372745335719};

ycord={347.543166449207,    461.536311618993,   261.753095520236,   431.778284592051,   250.920713280060,   432.113192132818,   1044.66583584371,   1044.70069210915,   1135.19457237168,   984.121301679063,   792.153882418914,   708.946190878097};
``````

Also, these are the edges connecting the nodes.

``````Edges={{1,2},{1,3},{1,8},{1,11},{1,12},{2,3},{2,4},{2,7},{2,8},{2,11},{2,12},{3,4},{3,5},{3,11},{3,12},{4,5},{4,6},{4,10},{4,11},{4,12},{5,6},{5,11},{5,12},{6,10},{6,11},{6,12},{7,8},{7,9},{7,10},{7,11},{7,12},{8,9},{8,11},{8,12},{9,10},{9,11},{9,12},{10,11},{10,12},{11,12}};
``````

Let’s say, The weight of the edges are randomly generated.

I want to plot the graph. The nodes should be depicted as circles with the index within it. I also want to place the weight over the edges.

How can I do it?

## algorithms – inequivalent vertex weights on finite poset

Let $$mgeq1$$ and $$P$$ be an arbitrary poset with vertex set $$V={v_1,dots,v_n}$$, edge set $$E,$$ and set $$O$$ of orbits under $$text{Aut}(P).$$ Can we efficiently generate all inequivalent nonnegative weight assignments $$alpha:Vtomathbb{N}$$ such that $$sum_{i=1}^nalpha(v_i)=m$$ from this information alone or do we need all inequivalent $$alpha$$ with sum $$leq m$$ for all $$|P| My goal is to obtain them for every $$P$$ (up to isomorphism) with $$|P|leq10$$.

If an inductive procedure is needed, maybe it will involve something along the following lines.

Fix an orbit $$oin O$$ and weight assignment $$alpha$$ on $$Vsetminus o$$ with sum $$m-m’.$$ For each $$vin o$$ and orbit $$o’neq o,$$ let $$N_alpha(v,o’,w)$$ be the number of incoming edges to $$v$$ from vertices in $$o’$$ with weight $$w.$$ For each $$v_i,v_jin o$$ we set $$v_isim_{o’}v_j$$ iff $$N_alpha(v_i,o’,w)=N_alpha(v_j,o’,w)$$ for all $$wgeq0,$$ and $$v_isim v_j$$ iff $$v_isim_{o’}v_j$$ for all $$o’neq o.$$

Let the equivalence classes under $$sim$$ have cardinalities $$a_1,dots,a_h.$$ For each composition $$(c_1,dots,c_h)$$ of $$m’$$ with nonnegative parts (one part to each class), we compute all possible combinations of partitions of $$c_i$$ with $$a_i$$ nonnegative parts (one part to each vertex).

I think the weight assignments produced by these partitions will be inequivalent, as will the entire collection obtained by repeating the above for all inequivalent $$alphatext{‘s}$$ on $$Vsetminus o,$$ but major issues remain such as how do we choose $$o,$$ etc.

## c++ – Tower Defense: Sorting Algorithm with multiple weights (enemy AI)

I’m writing a sorting algorithm for a tower defense mobile game. As a quick synopsis, I have a “tower” that can shoot at incoming threats that are within X distance from the base of the tower.

Each incoming enemy, will have an associated {distance_from_tower} and {enemy_weight}. The {distance_from_tower} will be a value between 0 and X (X being the max range of the tower). The {enemy_weight} is a valued weight of “how important” it is to target that enemy mob. For example:

Three enemies:

Archer: {distance_from_tower} = 3 , {enemy_weight} = 1

Knight: {distance_from_tower} = 7 , {enemy_weight} = 5

Zombie: {distance_from_tower} = 10 , {enemy_weight} = 3

Currently, I have a simple sorting algorithm that only sorts enemies by their distance from the tower. (So, in the above example, the tower would target: Archer –> Knight –> Zombie)

Which is a “fine” first logical step, but I want my towers targeting to be more robust. I want the sorting to take into account both the {distance_from_tower} AND the {enemy_weight}. (For reference as well, these two values are updated at every Z seconds during the game, so they are constantly being recalculated).

I would like for the tower to be “smarter” and have a more robust sorting mechanism, that takes into account both weights, as said above. That could potentially lead to the tower targeting an enemy mob that is further away because the {enemy_weight} value of that respective enemy mob is of “high priority”. (So, in the above example, the inclusion of using both weights could lead to the tower targeting in this order: Knight –> Archer –> Zombie).

I’ve been digging around for a few possible solutions, such as using a Travelling Salesman approach, Dijkstra’s algorithm, or Floyd’s algorithm, and I can’t figure out the best way to go about sorting using both weights in a manner that makes sense to me. Any intuition or help is greatly appreciated! Thanks!

## Can I Take Protein To Train With Weights If I Am Hypertensive?

Can I take protein to train with weights if I am hypertensive?

## python – Initialize weights in pytorch with customized weight?

I want to initialize the weights of my neural network with parameters samples from a specific distribution, that is not already present in nn.init module. Let’s say for example a beta distribution.

I saw that you can use the method described there: Custom weight initialization in PyTorch

But there you need to use the nn.init. What is an elegant way to initialize weights from a distribution that I specify

## Graphs: colouring vertex weights differently from vertices

I use simultaneous display of vertices and weights (this topic is related to another question posted here)

I display vertices via the following code (only included for completeness)

``````vf({xc_, yc_}, name_, {w_, h_}) :=
Block({xmin = xc - w, xmax = xc + w, ymin = yc - h, ymax = yc + h},
Polygon({{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}));
``````

The graph edges are specified as:

``````relations = {x2 -> x6, x2 -> x7, x5 -> x6, x5 -> x7, x3 -> x2}
``````

The following code has a part that colors the vertex labels red

``````labeling(relations_, weights_) :=
Graph(relations,
VertexCoordinates ->
ReflectionTransform({0, -1})@GraphEmbedding(Graph(relations)),
VertexLabelStyle -> Directive(Red, 15),
VertexWeight -> weights, VertexShapeFunction -> vf)

g = labeling(relations, {1, 2, 3, 4, 5});
``````

The vertices xi and their weights are simultaneously displayed by:

``````g = SetProperty(
g, {VertexLabels ->
Table(i ->
Placed({i, PropertyValue({g, i}, VertexWeight)}, {Before,
After}), {i, VertexList(g)})})
``````

How can I display the weights in blue, but keep the vertices xi in red?

VertexLabelStyle allows me to set the colour red for vertex labels (displaying both vertices xi and their weigths red in the graph).

There is no VertexLabelStyle to set colours of weights (I believe).

I need to manipulate the weights and vertices separately in the graph, i.e. sometimes move the vertices (xi) which are to remain red and sometimes move the weights (integers) which need to remain blue.

## Faithful normal semi-finite weights

The Corollary is from Takesaki’s book (Vol 2, Chapter VIII).

By Theorem 2.11, we have $$sigma_t^{psi}(x)=h^{-it}sigma_t^{varphi}(x)h^{it}$$ for all $$xin M$$, how to prove (ii)→(i)?

## How to Retain Font Weights when Exporting Word Doc to PDF?

I’m trying to imitated LateX style typesetting in word by using a this word template. The main issue is that when exporting as a PDF, some of the bolded text appears as regular (`Computer Modern Family` font is installed).

I think this might be due to predefined weight a certain font has but is there a workaround to export PDF as it is in Word. (Below are examples of what I get)

## Find cycles with specific weights in complete graph

Assume I have an undirected edge-weighted complete graph $$G$$ of $$N$$ nodes (every node is connected to every other node, and each edge has an associated weight). Assume that each node has a unique identifier.
Let’s say I then have an input cycle, $$c$$ which is just a list of weights (e.g $$c=(4,7,6)$$).
Does an algorithm exist that lets me search $$G$$ for the cycle $$c$$, and returns the identifiers of the matching nodes?
Here is a poorly-drawn example:
.

## weighted graphs – Find approximate ‘best’ matching pairs by calculating the fewest possible weights

My specific problem is as follows:

• Given two list of texts (in the order of 5 to 50 items)
• Find best matching pairs with their corresponding matching score (weight)
• Where each item can only be matched once with another item (from the other list)
• While minimizing the calculation of the weights (edit distance in my case)
• Every score can be between 0.0 (no match) and 1.0 (perfect match)
• I may only require pairs to be matched, that meet a certain threshold

Because the edit distance is quite expensive to calculate, it is the bottleneck.
At the same time, I may be able to exclude some edges by calculating the upper limit (if they don’t meet the threshold).

I guess this could be a special case of the assignment problem.

Assuming the size of list 1 is `n` and the size of list 2 is `m`.

It seems in order to apply most common algorithm, one need to calculate all of the scores between all possible pairs.
i.e. in this case it would be `n * m`

One approach I tried to far is:

• Copy `list 2` to `remaining list 2`
• For each `item 1` in `list 1`
• Find best match meeting threshold of `item 1` in `list 1`:
• Copy `remaining list 2` to `temp list 2`
• Sort `temp list 2` by `approximate score` between `item 1` and each item in `temp list 2` (in descending order)
• Remove items from `temp list 2` where approximate score is below threshold
• For each `item 2` in `temp list 2`:
• Calculate a `expensive score` between `item 1` and `item 2`
• If `expensive score` is `1.0`: Return pair between `item 1` and `item 2`
• If `expensive score` is meeting threshold: Save `item 2` as `best matching item 2`
• Return pair between `item 1` and `best matching item 2`
• Remove `item 2` of matched pair from `remaining list 2`

I am thinking this can probably be improved by initially using the first found matching pair meeting the threshold.
And then later see if unmatched `item 1` can be matched with an already paired `item 2`, whereas `item 2` could also be matched with another `item 1`.

Do any existing algorithms address a similar problem?