java – Minimizing the path of a file

I have a simple program that "minimizes" a file path. Minimize simply means replacing unnecessary file entries with entries that mean the same thing:

  • route1 / route2 /../ route3 is replaced by route1 / route3
  • route1 /./ route2 is replaced by route1 / route2

I achieved this using regular expressions and it seems to cover all cases, but it also feels very slow and I have a hunch that I might be prone to infinite loops:

final static private pattern ONE_DOT = Pattern.compile ("/\./");
static final private pattern TWO_DOTS = Pattern.compile ("[^/]+ / \ \ ./? ");

Public static chain minimize (Final chain in) {
String tmp = en;
while (! stringIsMinimized (tmp)) {
tmp = ONE_DOT.matcher (tmp) .replaceAll ("/");
tmp = TWO_DOTS.matcher (tmp) .replaceAll ("");
}
returns tmp;
}

public Boolean static stringIsMinimized (final string chain) {
return! (ONE_DOT.matcher (str) .find () || TWO_DOTS.matcher (str) .find ());
}

Path Finder – Is there a magic item in which you can use mythical points and then launch the mythical version of that spell?

Ring of Transcendent Spells is the closest to what you are looking for. You will have to scroll down to find it. I even had to ask my own question about it at any given time.

Now the ring means that you do not have to KNOW the mythical version of the spell, but it also means that you can not increase it. So, although it is a very versatile item, it still has a small flaw.

Now, the normal rules are that when you cast a spell using a magic item, it does not benefit from your abilities like CL or skill score. There are ways to avoid this. But unfortunately healing minor injuries is not a mythical healing of minor injuries, so the object is different.

np complete – Demonstrating NP integrity of the maximum length path

I have this question to answer:

For each node i in a non-directed network $ G = (N, E) $, leave $ N (i) = {j in N: {i, j } in E } $ denotes the set of node neighbors $ i $ and let $ c_e geq0 $ denotes the length of the edge $ e in E $. For each node $ i in N $suppose
set $ N (i) $ It is divided into two subsets, $ N ^ + (i) $ Y $ N ^ – (i) $ such that $ j in N ^ + (i) (j in N ^ – (i)) $ is referred to as a positive (negative) neighbor of $ i $. (Note: regardless of whether $ j $ is a positive or negative neighbor of
$ i $, $ i $ can be a positive or negative neighbor of j.) Consider the problem of finding a maximum length
path $ (s =) i (0) -i (1) – ··· -i (h) (= t) $ in $ G $ between two nodes $ s ∈ N $ Y $ t ∈ N $ Subject to the following restriction: For each internal node $ i (k) (k in {1, …, h – 1 }) $ on the road, the whole $ {i (k – 1), i (k + 1) } $ must contain exactly one positive neighbor and one negative neighbor of $ i (k) $. Show that NP is complete in the decision problem and indicate whether it is strongly NP-completed or not.

I wonder about the steps of the test and whether I should start from the problem of the longest route or from another instance of the problem.

google search: Can I use BreadcrumbList Structured Data on my site if I do not show a navigation path on the page or in my URL structure?

I have read that Breadcrumbs helps Google to better understand the structure of your site, so I would like to implement it in mine. However, I currently do not have a trace of the navigation path visible on the site. Does this go against the best practices to have the markup, but not to show it visually to the user?

Also, I do not have bread crumbs in my URL structure. So, in the article pages, the URL is like this: https://example.com/article-slug/, and the subcategory pages do not show the top-level category: for example, use https://example.com / camping -gear / instead of https://example.com/outdoors/camping-gear.

Can I still implement BreadcrumbList despite these two factors?

What is the best learning path for a beginner programmer?

I have basic knowledge of c ++. What would be the best languages ​​to focus on becoming professional programmers in a short space of time?
I was also looking to focus on software development.

Theory of complexity – Decision problem – Vertex with path to all other vertices

Suppose you give us a graph directed $ G $ and two vertices $ s, t $. Add a new vertex $ a $ and an advantage of $ a $ to $ s $. Also, add a border of $ t $ to all the vertices in the graph other than $ a $.

As $ a $ it does not have incoming edges, if there is any vertex from which all other vertices are accessible, it must be $ a $. For this to happen, in particular. $ t $ it must be accessible from $ a $. From the only projecting edge of $ a $ point to $ s $, this can only happen if $ t $ it is accessible from $ s $. In that case, all other vertices are also accessible from $ a $through $ t $, since we add outgoing edges of $ t $ to all vertices apart from $ a $.

Benchmarking k-shorter path algorithms in Java without JMH

In this post, I have the demo controller that makes two reference points $ k $Shortest route algorithms. The entire GitHub project is here. Next, my code continues:

net.coderodde.graph.kshortest.Demo

net.coderodde.graph.kshortest package;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import net.coderodde.graph.DirectedGraphNode;
import net.coderodde.graph.DirectedGraphWeightFunction;
import net.coderodde.graph.kshortest.impl.DefaultKShortestPathFinder;
import net.coderodde.graph.kshortest.impl.FasterDefaultKShortestPathFinder;

public class demo {

int static private end WARMUP_ITERATIONS = 5;
int private final private BENCHMARK_ITERATIONS = 20;
int private final private GRAPH_NODES = 5_000;
static int private end GRAPH_ARCS = 50_000;
final static private double MAX_WEIGHT = 1000.0;
static final private int K = 25;

empty main public static (String[] args) {
demo1 ();
long seed = System.currentTimeMillis ();
Random random = new random (seed);
List graph = constructGraph (GRAPH_NODES,
GRAPH_ARCS,
random);
DirectedGraphWeightFunction weightFunction =
new DirectedGraphWeightFunction ();

addArcWeights (graphic, weightFunction, MAX_WEIGHT, random);
System.out.println ("=== Graphic built! Heating ... ===");
heating (random, graphic, weight function, K);
System.out.println ("=== Full Warm Up! Benchmarking ... ===");
reference point (random, graphic, weightFunction, K);
}

Final static private list
         constructGraph (int graphNodes,
int graphArcs,
Random Random) {
List graph = new ArrayList <> (graphNodes);

for (int i = 0; i <graphNodes; i ++) {
graph.add (new DirectedGraphNode (i));
}

for (int i = 0; i <graphArcs; i ++) {
DirectedGraphNode tail = choose (graphic, random);
DirectedGraphNode head = choose (graphic, random);
tail.addChild (head);
}

return chart;
}

static final private vacuum
addArcWeights (List graphic,
DirectedGraphWeightFunction weightFunction,
double maxWeight,
Random Random) {
for (DirectedGraphNode tail: graph) {
for (DirectedGraphNode head: tail.children ()) {
weightFunction.put (tail, head, random.nextDouble () * maxWeight);
}
}
}

static empty private
heating (random chance,
List graphic,
DirectedGraphWeightFunction weightFunction,
int k) {
run fake
WARMUP_ITERATIONS,
random,
graphic,
Function weight
k);
}

static private reference index (random randomized,
List graphic,
DirectedGraphWeightFunction weightFunction,
int k) {
run
BENCHMARK_ITERATIONS,
random,
graphic,
Function weight
k);
}

Private static list 
        Random nodes (List graphic,
Randomly,
int size) {
List nodes = new ArrayList <> (size);

for (int i = 0; i <size; i ++) {
nodes.add (choose (graphic, random));
}

return nodes;
}

static static vacuum execution (Boolean printing,
int iterations,
Randomly,
List graphic,
DirectedGraphWeightFunction weightFunction,
int k) {
AbstractKShortestPathFinder finder1 = new DefaultKShortestPathFinder ();
AbstractKShortestPathFinder finder2 =
new FasterDefaultKShortestPathFinder ();

List sourceNodes = randomNodes (graphic,
random,
iterations);

List targetNodes = randomNodes (graphic,
random,
iterations);

List <List> results1 = new ArrayList <> (iterations);
List <List> results2 = new ArrayList <> (iterations);

long nanoTotalDuration1 = 0L;
long nanoTotalDuration2 = 0L;

for (int iter = 0; iter <iterations; iter ++) {
DirectedGraphNode sourceNode = sourceNodes.get (iter);
DirectedGraphNode targetNode = targetNodes.get (iter);

long startTime = System.nanoTime ();
List result1 =
finder1.findShortestPaths (
sourceNode,
targetNode,
weight function, k);
long endTime = System.nanoTime ();
long nanoDuration = endTime - startTime;
nanoTotalDuration1 + = nanoDuration;

if (print) {
System.out.println (finder1.getClass (). GetSimpleName () + "in" +
(long) (1e-6 * nanoDuration) +
"milliseconds");
}

nanoTotalDuration1 + = nanoDuration;
results1.add (result1);
}

for (int iter = 0; iter <iterations; iter ++) {
DirectedGraphNode sourceNode = sourceNodes.get (iter);
DirectedGraphNode targetNode = targetNodes.get (iter);

long startTime = System.nanoTime ();
List result2 =
finder2.findShortestPaths (
sourceNode,
targetNode,
weight function, k);
long endTime = System.nanoTime ();
long nanoDuration = endTime - startTime;
nanoTotalDuration2 + = nanoDuration;

if (print) {
System.out.println (finder2.getClass (). GetSimpleName () + "in" +
(long) (1e-6 * nanoDuration) +
"milliseconds");
}

results2.add (result2);
}

if (print) {
System.out.println (
"Algorithms of agreement:" + results1.equals (results2));

System.out.println (
finder1.getClass (). getSimpleName () + "in  n" +
(long) (1e-6 * nanoTotalDuration1) + "milliseconds.");

System.out.println (finder2.getClass (). GetSimpleName () + "in  n" +
(long) (1e-6 * nanoTotalDuration2) + "milieconds.");
}
}

private static  T choose (List list, random random) {
return list.get (random.nextInt (list.size ()));
}

private static demo demo1 () {
// 1 4
// /  / 
// 0 3 6
//  /  / /
// 2 5

DirectedGraphNode a = new DirectedGraphNode (0);
DirectedGraphNode b = new DirectedGraphNode (1);
DirectedGraphNode c = new DirectedGraphNode (2);
DirectedGraphNode d = new DirectedGraphNode (3);
DirectedGraphNode e = new DirectedGraphNode (4);
DirectedGraphNode f = new DirectedGraphNode (5);
DirectedGraphNode g = new DirectedGraphNode (6);

// The edges on line 0 - 6 have a weight of 1.0.
// The borders below line 0 - 6 have a weight of 2.0
DirectedGraphWeightFunction weightFunction =
new DirectedGraphWeightFunction ();

a.addChild (b); weightFunction.put (a, b, 1);
a.addChild (c); weightFunction.put (a, c, 2);
b.addChild (d); weightFunction.put (b, d, 1);
c.addChild (d); weightFunction.put (c, d, 2);

d.addChild (e); weightFunction.put (d, e, 1);
d.addChild (f); weightFunction.put (d, f, 2);
e.addChild (g); weightFunction.put (e, g, 1);
f.addChild (g); weightFunction.put (f, g, 2);

List routes = new FasterDefaultKShortestPathFinder ()
.findShortestPaths (a, g, weightFunction, 5);

for (Path: routes) {
System.out.println (Arrays.toString (path.getNodeList (). ToArray ()));
}
}
}

Sample output

The typical output follows:




Algorithms of agreement: truth
DefaultKShortestPathFinder in
31517 milliseconds
FasterDefaultKShortestPathFinder in
1304 millieconds

Critical request

Please, tell me anything you can think of.

changing the public file system path

How can I change the path of the public file system in Drupal 8?

You can add the following line to any of your settings.php file, or its settings.local.php case file. E.g. docroot / sites / default / settings.php

$ configurations['file_public_path']  = & # 39; / sites / default / files / my_custom_folder & # 39 ;;

And can you say more about how to increase the storage of the database?

I have no idea what it means.

Is it possible to use the route alias token as a file path with the filefield_paths module?

I would like to use the route alias to create the folder structure of the loaded file. First, I could not find the correct token in the list and after a while I decided to create my own custom token.

It was working when the node had already been created and a new file had been added, but it failed when the node was created for the first time. It also failed with the active update. It seems that the token was not called again …

I also found those 2 hooks that could be useful, but they did not go very far: I should use hook_entity_presave () or hook_filefield_paths_process_file ()

I would appreciate some advice on how you could implement such a feature.

Thank you

Graph theory: proof that the shortest path with negative cycles is difficult NP

I'm looking for the shortest path problem and I'm wondering how to try that shorter path with neg. The cycles are NP-hard. (Or is it NPC? Is there a way to validate in time P that the path really is shorter?)

How would you reduce the SAT problem to the shortest route problem in polynomial time?