How can Kruskal’s algorithm return different spanning trees?

We assume that we have the same graph G.

In introduction to Algorithms by Cormen it’s said that it`s possible depending on how it breaks ties when the edges are sorted into order.

I have trouble visualizing the answer given:

Suppose that A is an empty set of edges. Then, make any cut that has (u, v) crossing it. Then, since that edge is of minimal weight, we have that (u, v) is a light edge of that cut, and so it is safe to add. Since we add it, then, once we finish constructing the tree, we have that (u, v) is contained in a minimum spanning tree.

What does it mean to make a cut? I`m familiar with Kruskal’s algorithm but nowhere in the process do I see cuts being made. It’s either we unite two trees and add the edge to A or we reject the edge and continue on.

Return a ranking points of User follow week, month, year from multiple table with mySQL

Here is the structure of my tables:

User

|--------|------------| | id     | name       | |--------|------------| | 1      | Name1      | | 2      | Name2      | | 3      | Name3      | |--------|------------| 

Post

|--------|------------|-------------|--------------------| | id     | content    | user_id     |   created_at       |  |--------|------------|-------------|--------------------| | 1      | Content1   |  1          |2020-01-17 14:03:31 | | 2      | Content2   |  1          |2020-01-17 16:18:23 | | 3      | Content3   |  2          |2020-01-17 16:29:13 |  |--------|------------|-------------|--------------------| 

Comment

|--------|------------|-------------|----------|---------------------| | id     | comment    | user_id     | post_id  |   created_at        | |--------|------------|-------------|----------|---------------------| | 1      | Comment1   |  1          |   1      | 2020-01-20 18:29:19 | | 2      | Comment2   |  1          |   1      | 2020-01-22 17:25:49 | | 3      | Comment3   |  2          |   2      | 2020-01-28 11:37:59 |  |--------|------------|-------------|----------|---------------------| 

Vote

|--------|-------------|----------|-----------------------| | id     |  user_id    | post_id  |    created_at         | |--------|-------------|----------|-----------------------| | 1      |   1         |   1      | 2020-01-20 15:08:55.0 | | 2      |   1         |   2      | 2020-01-20 15:13:29   | | 3      |   2         |   2      | 2020-01-20 15:13:32   | |--------|-------------|----------|-----------------------| 

I want to find the top score of 10 users by week, month, the year following to formula:

A user creates 1 post will have 10 points. A user creates 1 comment in a post that will have 5 points. A user votes in a post that will have 2 points. Could anyone help me with this, please!

Thank you so much.

return multiple element in save() and richtext is not working

So I have made two blocks, one called reference and one called reference holder. Reference is a child block of Reference holder. Reference holder is responsible for generating <ul> and Reference is responsible for generating <li> with a RichText field.

I want to add another above the <ul> in Reference holder, so I turn the returned elements into an array, but then the RichText field is not working. I am sure this is related with the array, but I have no idea how to solve it.

Reference Holder block (returning an array)

(() => {     const __ = wp.i18n.__; // The __() for internationalization.     const el = wp.element.createElement; // The wp.element.createElement() function to create elements.     const registerBlockType = wp.blocks.registerBlockType; // The registerBlockType() to register blocks.      const ServerSideRender = wp.components.ServerSideRender;     const TextControl = wp.components.TextControl;     const TextareaControl = wp.components.TextareaControl;     const InspectorControls = wp.editor.InspectorControls;     const { RichText } = wp.blockEditor;     const { InnerBlocks } = wp.blockEditor;      //Custom variable     const allowedBlocks = [ 'custom-blocks/ref' ] ;     const blockTemplate = [ [ 'custom-blocks/ref', {} ] ];      registerBlockType( 'custom-blocks/ref-holder', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.         title: __( 'Reference Holder', 'custom-blocks' ), // Block title.          category: 'custom_block',         keywords: [ __('ref'), 'custom-blocks'],         attributes: {          },         supports: {             customClassName: false,             className: false,         },          edit(props) {              return [el('h2', {}, __('Reference', 'custom-blocks') ), el(                 'ul', { className: 'ref-block-holder'},                 el ( InnerBlocks,                 {                     allowedBlocks: allowedBlocks,                     template: blockTemplate                 } )             )];         },          save(props) {              return [el('h2', {}, __('Reference', 'custom-blocks') ), el(                 'ul', { className: 'ref-block-holder'},                 el ( InnerBlocks.Content,                 {                     allowedBlocks: allowedBlocks,                     template: blockTemplate                 } )             )];         },     }); })(); 

Reference block

(() => {     const __ = wp.i18n.__; // The __() for internationalization.     const el = wp.element.createElement; // The wp.element.createElement() function to create elements.     const registerBlockType = wp.blocks.registerBlockType; // The registerBlockType() to register blocks.      const ServerSideRender = wp.components.ServerSideRender;     const TextControl = wp.components.TextControl;     const TextareaControl = wp.components.TextareaControl;     const InspectorControls = wp.editor.InspectorControls;     const { RichText } = wp.blockEditor;     const { InnerBlocks } = wp.blockEditor;      /**      * Register Basic Block.      *      * Registers a new block provided a unique name and an object defining its      * behavior. Once registered, the block is made available as an option to any      * editor interface where blocks are implemented.      *      * @param  {string}   name     Block name.      * @param  {Object}   settings Block settings.      * @return {?WPBlock}          The block, if it has been successfully      *                             registered; otherwise `undefined`.      */     registerBlockType( 'custom-blocks/ref', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.         title: __( 'Reference', 'custom-blocks' ), // Block title.          category: 'custom_block',         parent: [ 'custom-blocks/ref-holder' ],         attributes: {             reference: {                 source: 'children',                 selector: 'li',             },         },         supports: {             customClassName: false,             className: false,         },          edit(props) {             const reference = props.attributes.reference;              function onChangeReference( newContent ) {                 props.setAttributes( { reference: newContent } );             }              const editReference = el(                 RichText,                 {                     tagName: 'li',                     onChange: onChangeReference,                     value: reference,                     formattingControls: [ 'bold' ],                     placeholder: __( 'Reference...', 'custom-blocks' ),                 }             );              return editReference;          },          // The "save" property must be specified and must be a valid function.         save(props) {             const reference = props.attributes.reference;              const referenceOutput = el ( RichText.Content,                 {                  tagName: 'li',                 value: reference,                 }                 );              return referenceOutput;         },     } ); })(); 

Any help will be appreciated. Thanks!

SQL – Return most recent batch of sequential rows

What i’m trying to accomplish here is pull in all the rows where there is a break of less than lets say 40 days between the next row.

So in the first example there is an uninterrupted break every month or roughly so is accounted for, so I would like the query to pull in all records here.

Example 1

ID          DATE(INT)      190402      20200205 190401      20200103 177904      20191205 177903      20191108 177902      20191001 177901      20190905 147512      20190802 147511      20190703 147510      20190603 147509      20190529 147508      20190429 147507      20190402 147506      20190306 147505      20190205 147504      20190110 147503      20181211 147502      20181115 147501      20181022 

In example two there is a gap greater than 40 days between Sep 25 2019 and January 29 2020. So I would like the query to just pull in the most recent subsequent block. In this case it would just be the top record.

Example 2

ID          DATE 189101      20200129 164705      20190925 164704      20190904 164703      20190802 164702      20190703 164701      20190605 

I have started down this road, and was looking at using LEAD to calculate the number of days between the current and previous rows. I realize I probably need to break the years out to account for the case when moving to a new year or convert it to a real date so that I can use some sql functions to calculate the difference in days for me.

After that I wasn’t sure how to go about only returning the most recent consecutive block. Thought I would ask here to see if anyone had any insight on how I to accomplish this.

calling mysql procedure return empty result

when i call procedure it gives me empty result

   call hussian('prstate','table_1','column1,column2,column3',1) 

it run but gives empty result, please help me…

 DELIMITER //    CREATE PROCEDURE hussain(IN src_col varchar(20),                       IN tblname varchar(100),                       IN col_names varchar(100),                       IN _leadid int)   BEGIN     IF (col_names  = 'column1' AND col_names  = 'column2'  AND col_names = 'column3') THEN      SET @sql = CONCAT('insert into ', tblname, '(',col_names,')', ' select ' ,src_col,',','firstname,lastname from tbllead where id = ',_leadid);      PREPARE s1 from @sql;      EXECUTE s1;     DEALLOCATE PREPARE s1;  END IF;   END //   DELIMITER ;  

it insert data into table when i romove if condition…..

Why does this code return $\frac{count}{2}$ instead of $count$?

I am reading “Algorithms 4th Edition” by Sedgewick & Wayne.

The following method computes the number of self loops of an undirected graph $ G$ .
Why does this code return $ \frac{count}{2}$ instead of $ count$ ?
I think self loop appears in adjacency list only once.

// number of self-loops public static int numberOfSelfLoops(Graph G) {     int count = 0;     for (int v = 0; v < G.V(); v++)         for (int w : G.adj(v))             if (v == w) count++;     return count/2;   // self loop appears in adjacency list twice }  

Thank you for your comment, Zach Langley.
Now I have read the following code, and I understand why the above code is right.

 /**  * Adds the undirected edge v-w to this graph.  *  * @param  v one vertex in the edge  * @param  w the other vertex in the edge  * @throws IllegalArgumentException unless both {@code 0 <= v < V} and {@code 0 <= w < V}  */ public void addEdge(int v, int w) {     validateVertex(v);     validateVertex(w);     E++;     adj[v].add(w);     adj[w].add(v); } 

WordPress Query doesn’t return the correct value

According to this page:

Return #Return

(int|bool) Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error.

From this, I can see that I should get a “number of rows affected” value returned, however – it’s returning false.

Usually, this indicates an error and can see that a bool false on return = error. But this is where it gets a bit weird, the data is updated, yet the query is apparently a fail?

This my current code:

if (!$  this->conn->query($  this->conn->prepare($  this->qry, $  values))) {     var_dump($  this->conn->print_error()); } 

which prints:

<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> []<br /><code>UPDATE `wp_eng_dm_dealers` SET name = &#039;foo&#039;, blurb = &#039;trey&#039;, email = &#039;foo@dummy.com&#039;, tel = &#039;123456&#039;, www = &#039;https://google.com/&#039;, addr_line_1 = &#039;some place&#039;, addr_line_2 = &#039;&#039;, addr_line_3 = &#039;&#039;, town = &#039;A town&#039;, county = &#039;county&#039;, post_code = &#039;SOME PLACE&#039;, lat = XYZ, lng = XYZ, dealer_type_id = 1, dealer_of_the_month = 1 WHERE id = 4</code></p></div>NULL 

using the last_error property, I got:

string(0) “”

decoding the code wrapped in the <code> tag, I get a valid SQL statement, yet my conditionals never work because WP is returning a successful update as false. How can I go about debugging and resolving the issue?

WordPress version: 5.3.2