Consider 3 sequence 2n,3n,5n make combination of these 3 sequence into y sequence.then how find terms in increasing weight of number?

2n=2,4,6,8,10,12,14,16,…
3n=3,6,9,12,15,18,21,27,..
5n=5,10,15,20,25,30,35,40,45,..
Combination of sequence-
(2n,3n,5n)=y=2,3,4,5,6,8,9,10,12,14,15,16,18,20,21,22,24,25,…
How find terms in y in increasing order(weight)?
But we easily find combination of 2 sequence. let combination of (2n,3n)then terms in that seq. (2n,3n,2n,3n,2n,3n,2n,3n,….)but problem in combination of more than 2 sequence.is there formula?

Can the Bellman-Ford Algorithm be used to find the longest path in an undirected graph through first negating the weight of all the edges?

I understand that the Bellman-Ford Algorithm can solve the single-source shortest-paths problem. However, can it also be used to determine the longest path in an undirected, graph through first negating the weight of all the edges?

rt.representation theory – Action of the Casimir on highest weight modules for Kac-Moody algebra

Let $g$ be a Kac-Moody algebra with a symmetrizable Cartan matrix, and let ${u_j}$ and ${u^j}$ be bases of $g$ dual with respect to a nondegenerate invariant bilinear form $(cdot|cdot)$ on $g$, and consistent with the triangular decomposition of $g$. Let $L(Lambda)$ be an integrable representation of $g$ with highest weight $Lambda$, and let $v_Lambda$ be its highest weight vector. Denote the Casimir $Omega=sum_j u_jotimes u^j$.

I want to know why $Omega(v_Lambdaotimes v_Lambda)=(Lambda|Lambda)v_Lambdaotimes v_Lambda$? Could someone give some explanation or some references?

minimum spanning tree – Find MST on grid graph with only weight of 1 and 2 in $O(|V|+|E|)$

Given a grid graph $G=(V,E)$ which has only two different integer costs/weights of 1 and. Find Minimum Spanning Tree in $O(|V|+|E|)$.

I tried the following:

  • Changing Kruskal using a counting Sort in $O(|E|)$. But can I say that this results in O(|E|+|V|)? Since Kruskal would normally be ${displaystyle O(T_{sort}(|E|)+|E|cdot alpha (|V|))} =O(|E|)$ when $alpha (|V|) in O(1)$ Can this be stated for this case? I lack detailed understanding of inverse ackerman behaviour.
  • Other possibility changing Prim so that I use a priority queue which support del_min, decreaseKey and insert in $O(1)$. I thought about using two simple stacks or queues and only del_min from the one, which holds the 1 integers, but descreaseKey seems not efficient since I have to loop through the lists to find the elements. So maybe combine this with some kind so hash mapping to directly access each element in $O(1)$ for decreaseKey?

Both seem really close to the actual result, though I am struggling to see the right solution for this case.

development – Unable to permanently change the font size and weight inside a sharepoint modern page (the class name keeps changinag)

You could use the column formatting to do that.

In your list, select the column you want to change > column settings > format this column. then advanced mode and put the JSON below – preview and save

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "font-size": "15px",
    "font-weight":"bold"
  },
  "txtContent": "@currentField"
}

Since you are formatting a Person or Group, use the following

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "font-size": "20px",
    "font-weight":"bold"
  },
  "txtContent": "@currentField.title"
}

The difference is in the @currentField.title

8 – Field weight in display mode is not respected on custom entity

After debugging the DrupalCoreFieldFormaterBase on how the fields getting rendered, it seems the weights are getting applied to each field in DrupalCoreEntityEntityViewBuidler, but they are not getting rendered in the order at the entity level.

So providing a theme for the entity using hook_theme and a preprocess solves this issue. Here is the code:

// mymodule.module

use DrupalCoreRenderElement;

/**
 * Implements hook_theme().
 */
function mymodule_theme() {
  return (
    'myentity' => (
      'render element' => 'elements',
    ),
  );
}

/**
 * Prepares variables for myentity templates.
 *
 * Default template: myentity.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - elements: An associative array containing the entity
 *     information and any fields attached to the entity.
 *   - attributes: HTML attributes for the containing element.
 */
function template_preprocess_myentity(array &$variables) {
  foreach (Element::children($variables('elements')) as $key) {
    $variables('content')($key) = $variables('elements')($key);
  }
}
<!-- myentitty.html.twig -->
<article{{ attributes }}>
  {% if content %}
    {{- content -}}
  {% endif %}
</article>

plugins – How to display a simulator for shipping rate by size, weight and location on the frontpage?

I would like to know if there is a plugin I can use to display a simulator on the frontpage.
In my platform, I just take care of forwarding packages that my clients have already purchased on other platforms that doesn’t deliver to them (outside the us).
I need to give my clients a quote (on the frontpage), based on size, weight and address, so they know much they should pay if they use my service. Currently, I use UPS for the delivery.
I think the plugin should use an api call so I can get the correct price (negotiated price UPS), add my marge and give the quote.
I hope I am understandable.

Thank you very much for your help

discrete mathematics – Prove without using the Bellman-Ford algorithm that if the weight function is conservative in a graph, then there exists a feasible potential

Let $G=(V,E,W)$ is a directed graph, where $V$ is the set of vertices, $E$ is the set of edges, and $W: E rightarrow mathbb{R}$ is a weight function.
$W$ is said to be conservative if the sum of weights is nonnegative for each cycle of $G$.
Denote the tail and the head of an $e in E$ with ${rm tail}(e)$ and ${rm head}(e)$, respectively.
The $pi: V rightarrow mathbb{R}$ is called a feasible potential if $W(e) – pi({rm head}(e)) + pi({rm tail}(e)) ge 0$.
How to show without using the Bellmann-Ford-based shortest paths that if $W$ is conservative in $G$, then there is a feasible $pi$ potential for $G$?

algorithms – Approximate max weight path in directed graph

Context

This question is related to the fact one can’t use Bellman-Ford to find max weight paths in directed graphs with cycles. The reason is that giving a new graph $tilde{G}$ with negative weights (e.g. $tilde{w}_{ij} = – w_{ij}$) will result in cycles with negative sum, thus no minimum cost walk exists in $tilde{G}$.

General question

How well can we approximate the maximum weight path between $i$ and $j$ in $G$, using the shortest path algorithm on a graph $tilde{G}$ with transformed weights $tilde{w}_{ij}$ ?
In my case, one has $w_{ij}inmathbb{N}setminus{0}$. The transformed weights $tilde{w}_{ij}$ can be obtained using any function, but I assume a decreasing function $f$ is well adapted so that $w < w’ iff f(w) > f(w’)$.

My approach

I am currently trying to use $f(w) = dfrac{1}{w}$, in this context we have two important paths given a fixed path length $L$.

Denote a path $p = (i_0i_1, i_1i_2, i_2i_3, dots i_{L-1}i_L$) with weights $W = (w^{(1)}, w^{(2)}, w^{(3)}, dots, w^{(L)})$,

denote the maximum weight path of length $L$ by $p^*$ with weights $W^*$ achieving
$$ W^* = argmax_W{mathtt{Cost}(W)} = argmax_W sum_{k=1}^L w^{(k)}$$
and the path $p_*$ achieving minimum transformed cost with weights $W_*$
$$ W_* = argmin_W sum_{k=1}^L tilde{w}^{(k)} = argmin_W sum_{k=1}^L f(w^{(k)}) = argmin_W sum_{k=1}^L dfrac{1}{w^{(k)}}$$

Specific question

In this specific context, do we have the approximation $mathtt{Cost}(W^*) approx mathtt{Cost}(W_*)$ ?

Or is it “very wrong” to replace $W^*$ by $W_*$ ? What would be the distribution of the relative error defined as
$$E_r = dfrac{lvertmathtt{Cost}(W^*) – mathtt{Cost}(W_*)rvert}{mathtt{Cost}(W^*)}$$

Statistical analysis

I have tried a quick statistical analysis as follows:

  • Letting $Lin{3,4,5,6,7,8}$
  • sampling $w sim mathrm{Uniform}(1,w_{max})$
  • The value for $w_{max}$ was also picked from the set ${50, 100, 150, 200, 500}$
  • for each combination of $L,w_{max}$ I computed $10^5$ values of $W^*, W_*$ using $10^3$ candidate weights $W_i$

The results:

  • In $80.8%$ of cases we have $mathtt{Cost}(W^*) = mathtt{Cost}(W_*)$ and even better $W^*=W_*$
  • When computing the relative error $E_r$ one finds that $82.6%$ of error values are less than $0.001$, $89.7%$ less than $0.01$ and $99.9%$ less than $0.1$

The histogram for $E_r > 0$ is as follows

relative_error distribution

algorithms – Find an minimum weight elementary path with a given constraint

I have a problem as below and I am really stuck with it as it run with more than the time I desired (about 1 second). I really want your help to build up a more efficient algorithms than mine

Given an undirected graph G = (V, E) with two parameter of weights w1 and w2 for each edges. This graph has N vertices and M edges. A K-Elementary path S is a sub-graph of G which must be an elementary graph and it does have exactly K edges.

Find a K-elementary path S with the sum of w1 of all edges as minimum value and the sum of w2 of all edges of S must be smaller than a given value Q. If it does not exist any path satisfied, print out the value -1

Input:

The first line with four values N, M, K, Q (2 <= N, K <= 50, 1 <= M <= 2*N, 1 <= Q <= 10^9)

The next M lines show the edges of the graph: V1 V2 W1 W2 (1 <= V1, V2 <= N, 1 <= W1 <= 10^4, 1 <= W2 <= 10^4)

Output: One integer to show the minimum weight of the k-elementary graph found. -1 if non-exists

Sample test case:

Input:

5 7 3 6
1 2 1 2
1 4 2 2
1 5 3 6
2 3 3 2
2 4 4 4
3 4 5 1
4 5 4 7

Output:

6

First of all, I want to quote the definition of an elementary path.

In short, for this problem, we need to find an k-elementary path S such that the weight to w1 is minimum, the sum of all edges to w2 is less than or equal to Q and it does have exactly K edges.

I do have a Backtracking approach, in which I tried to build up all the graph satisfying the second condition (w2) and then find the minimum of the first condition (w1) but, as you have known, the time complexity is quite high. However, I find it hard to convert it to dynamic programming or any other methods to reduce to time complexity. I do add some Branch-bound condition but it is still slow.

Below is my source code which you can refer but I do not think it is useful

#include <bits/stdc++.h>
using namespace std;
#define N 51
#define INF 1e9
int n, m, K, Q;
bool appear(N);
int W1(N)(N);
int W2(N)(N);
int currentSum1 = 0;
int currentSum2 = 0;
int source = 0;
int res = INF;
int Log(N);
int minElement = INF;
bool check(int k, int v)
{
    return !appear(v) && W1(Log(k - 1))(v) != 0 && W2(Log(k - 1))(v) != 0;
}
void solution()
{
    if(currentSum1 != 0 && currentSum1 < res)
    {
        res = currentSum1;
        // for(int i = 0; i <= K; i++)
        //     cout << Log(i) << " ";
        // cout << endl;
    }
}
void solve(int k)
{
    for(int v = 1; v <= n; v++)
    {
        if(check(k, v) && currentSum2 + W2(source)(v) <= Q && currentSum1 + (K - k) * minElement <= res) //Branch-bound condition
        {
            Log(k) = v;
            currentSum2 += W2(Log(k - 1))(v);
            currentSum1 += W1(Log(k - 1))(v);
            appear(v) = true;
            if(k == K)
                solution();
            else
                solve(k + 1);
            currentSum1 -= W1(Log(k - 1))(v);
            currentSum2 -= W2(Log(k - 1))(v);
            appear(v) = false;
        }
    }
}
int main()
{
    fast;
    // freopen("data.txt", "r", stdin);
    cin >> n >> m >> K >> Q;
    for(int i = 0; i < m; i++)
    {
        int x, y, w1, w2;
        cin >> x >> y >> w1 >> w2;
        minElement = min(minElement, w1);
        W1(x)(y) = w1;
        W1(y)(x) = w1;
        W2(x)(y) = w2;
        W2(y)(x) = w2;
    }
    for(int v = 1; v <= n; v++)
    {
        source = v;
        currentSum2 = 0;
        currentSum1 = 0;
        Log(0) = v;
        for(int i = 1; i <= n; i++)
            appear(i) = false;
        appear(source) = true;
        solve(1);
    }
    if(res != INF)
        cout << res << endl;
    else 
        cout << -1 << endl;
}