Agricultural product supply chain fragmentation method and device based on improved Louvain algorithm

By improving the Louvain algorithm and introducing reputation gain terms and multimodal weight modeling into the blockchain agricultural product traceability system, the problems of uneven node resource allocation and frequent cross-shard communication are solved, realizing efficient and reliable agricultural product supply chain sharding and improving system scalability and business adaptability.

CN120875342APending Publication Date: 2025-10-31BEIJING RES CENT FOR INFORMATION TECH & AGRI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510936691.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-08
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

Existing blockchain-based agricultural product traceability systems suffer from problems such as uneven distribution of node resources, frequent cross-shard communication, high latency, and high resource consumption in sharding technology. Furthermore, the traditional Louvain algorithm is out of touch with business scenarios in the agricultural product supply chain.

Method used

An improved Louvain algorithm is introduced, which adds a reputation gain term to the modularity and combines the average reputation value of nodes with the reputation difference between shards to design a two-level optimization objective function, thereby constructing a sharding scheme with strong business adaptability, including multimodal weight modeling and dynamic reorganization strategy.

Benefits of technology

It improves the scalability and reliability of business processes in the blockchain agricultural product traceability system, reduces cross-slice communication overhead, enhances the local adaptability of business processes, and ensures the stability and efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120875342A_ABST
    Figure CN120875342A_ABST
Patent Text Reader

Abstract

The invention provides an agricultural product supply chain fragmentation method and device based on an improved Louvain algorithm, and relates to the technical field of block chain fragmentation, and the method comprises the steps: carrying out the fragmentation of nodes in an agricultural product supply chain based on the improved Louvain algorithm; according to the improved Louvain algorithm, a reputation gain item is introduced on the basis of the modularity of a traditional Louvain algorithm, and the reputation gain item is formed based on the average reputation value of internal nodes of fragments and the average reputation difference between the fragments. According to the method, the agricultural product supply chain fragments with high business adaptability are constructed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain sharding technology, and in particular to a method and apparatus for sharding agricultural product supply chains based on an improved Louvain algorithm. Background Technology

[0002] In the context of agricultural product traceability across the entire supply chain, the industry chain covers multiple stages including planting, processing, logistics, and retail, resulting in long traceability chains, large time spans, and highly heterogeneous data types. While blockchain-based traceability systems employ chained storage and a network-wide consensus mechanism to ensure data immutability, they require nodes to store the entire ledger, leading to high storage costs and limited system scalability. To address the storage scalability issue, we need a method to improve the scalability of the traceability system.

[0003] Sharding is considered the most promising on-chain scalability solution, fundamentally reducing the resources required for each node and lowering the barrier to node configuration. Sharding technology allows blockchain networks to process tasks in parallel, reducing transaction processing time and thus transaction latency, significantly improving system scalability. However, the introduction of sharding technology also brings new challenges.

[0004] Existing sharding technologies often employ random sharding strategies, leading to uneven distribution of node resources and impacting overall system stability. Furthermore, random sharding fragments closely related nodes, requiring frequent cross-shard communication to maintain data consistency, thus increasing latency and resource consumption.

[0005] Against this backdrop, the Louvain algorithm was introduced to address the issues of uneven node performance distribution and high coordination costs. Although topology-aware sharding based on the Louvain algorithm can partially alleviate these problems, in agricultural product traceability scenarios, traditional algorithms rely solely on node connection density to divide communities, leading to a disconnect between sharding and actual business scenarios. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a method and apparatus for agricultural product supply chain segmentation based on an improved Louvain algorithm, aiming to construct an agricultural product supply chain segmentation scheme with strong business adaptability.

[0007] This invention provides a method for segmenting the agricultural product supply chain based on an improved Louvain algorithm, comprising the following steps: The improved Louvain algorithm is used to shard nodes in the agricultural product supply chain. The improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm. The reputation gain term is based on the average reputation value of nodes within a shard and the average reputation difference between shards.

[0008] In some embodiments, the sharding of nodes in the agricultural product supply chain based on the improved Louvain algorithm includes: The nodes in the agricultural product supply chain are layered based on role tags, resulting in multiple layers; each layer corresponds to a role tag. Within each layer, nodes are sharded based on the improved Louvain algorithm.

[0009] In some embodiments, the sharding of nodes based on the improved Louvain algorithm includes: Determine the initial community to which each node belongs; For the current node, perform the following: determine the neighboring communities of the current node; move the current node to each of the neighboring communities, calculate the modularity gain corresponding to each of the neighboring communities, and determine the neighboring community corresponding to the maximum modularity gain; if the maximum modularity gain is greater than 0, move the current node to the neighboring community corresponding to the maximum modularity gain. If the maximum modularity gain is greater than the modularity gain threshold, the next node is taken as the current node; If the maximum modularity gain is equal to or less than the modularity gain threshold, nodes in the same community are merged into supernodes to build a new network. This process is repeated iteratively until the modularity gain no longer increases.

[0010] In some embodiments, the method further includes: Fragments whose reputation variance is greater than the first threshold or whose ratio of cross-fragment interactions to internal interactions is greater than the second threshold will trigger reassembly.

[0011] In some embodiments, the method further includes: The edge weights between the two nodes are constructed based on the transaction closeness, geographical proximity, reputation correlation, and role correlation between them.

[0012] In some embodiments, the method further includes: Roles are assigned to each node according to the upstream and downstream sequence of the agricultural product supply chain; The role association degree between the two nodes is determined based on their role codes; the two nodes are two nodes that have a business relationship.

[0013] In some embodiments, the method further includes: The reputation value of each node is determined based on the transaction fulfillment rate and regulatory rating after standardized processing. The reputation values ​​of the two nodes are weighted and fused to obtain the reputation correlation between the two nodes.

[0014] This invention also provides an agricultural product supply chain segmentation device based on an improved Louvain algorithm, comprising the following modules: The layering module is used to stratify nodes in the agricultural product supply chain based on role tags, resulting in multiple layers; each layer corresponds to a role tag. The sharding module is used to shard nodes within each layer based on the improved Louvain algorithm. The improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm. The reputation gain term is based on the average reputation value of nodes within a shard and the average reputation difference between shards.

[0015] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the agricultural product supply chain sharding method based on the improved Louvain algorithm as described above.

[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the agricultural product supply chain segmentation method based on the improved Louvain algorithm as described above.

[0017] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the agricultural product supply chain sharding method based on the improved Louvain algorithm as described above.

[0018] The present invention provides a method and apparatus for agricultural product supply chain sharding based on an improved Louvain algorithm. On the basis of the modularity of the traditional Louvain algorithm, a reputation gain term composed of the average reputation value of nodes within a shard and the average reputation difference between shards is introduced. A two-level optimization objective function is designed, namely the collaborative optimization of "topology tightness + business credibility". This enables the sharding structure to reduce cross-shard communication overhead, ensure the credibility and locality of business processes, and improve the adaptability of business locality. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0020] Figure 1 This is one of the flowcharts of the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by this invention.

[0021] Figure 2 This is the second flowchart of the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by this invention.

[0022] Figure 3 This is a schematic diagram of the agricultural product supply chain segmentation device based on the improved Louvain algorithm provided by the present invention.

[0023] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0024] The agricultural product supply chain is divided into five major stages: planting, processing, warehousing, logistics, and sales. Data from the planting stage is transmitted to the blockchain via agricultural sensors, data collection, and communication equipment through an IoT platform. Then, in the crop processing stage, data related to the processing process is uploaded to the blockchain data layer. Data from the warehousing stage, including basic information about warehousing companies, environmental monitoring information, transaction records, and price information, also needs to be uploaded to the blockchain. Next, logistics transmission occurs, with logistics companies and transportation-related information uploaded to the blockchain. Finally, in the sales stage, data from the final stage—from distributors to dealers and ultimately to consumers—is uploaded to the blockchain data layer.

[0025] The planting stage includes basic information about the growers, planting methods, contact information, and the name of the planting base, as well as environmental and crop information. The processing stage includes four processes: grain soaking, milling, flour blending, and packaging. The warehousing stage includes information such as the name and address of the warehousing company, the legal representative's information, the warehouse manager's information, and prices. The warehousing stage comprises three stages: acquisition, impurity removal, and storage. The acquisition stage includes grower information, pesticide sampling records at the time of acquisition, agricultural product origin information, acquisition time, agricultural product type, acquisition location, and storage company information. The impurity removal stage includes information such as impurity types, impurity content, and impurity removal rate. The storage stage includes information such as storage company information, storage number, storage time, storage environment monitoring data (temperature and humidity control, environmental quality), stored product status records, and storage equipment and operation records. The logistics stage includes information such as the logistics company name, logistics company address, transportation manager information, license information, manager's contact information, means of transport, vehicle number (license plate number), departure point, time, destination, arrival time, and the internal temperature and hygiene conditions of the transport vehicle, temperature and humidity, and transportation costs. The sales process includes information such as merchant name, shop address, person in charge information, business license information, merchant contact information, product name, product quantity, purchase time, product storage time, product storage location, purchase number, shipping time, as well as basic information and hygiene conditions, sales photos, purchase price, and selling price.

[0026] To address the technical bottlenecks in existing technologies, this invention proposes a dynamic supply chain sharding method based on an improved Louvain algorithm, aiming to construct a blockchain sharding scheme with strong business adaptability and high dynamic elasticity. This scheme employs multimodal weight modeling, constructing a composite edge weight function that integrates transaction density, geographical proximity, reputation correlation, and role correlation. This embeds the multidimensional attributes of nodes and their business relevance into the community partitioning model, overcoming the limitation of traditional algorithms' single-dimensionality approach. A two-layer optimization objective function is designed, incorporating the intra-shard reputation mean and inter-shard differences into modularity optimization, enhancing business locality adaptability. Simultaneously, a hybrid triggering strategy based on reputation variance threshold and cross-shard transaction entropy is designed to reduce reorganization overhead. This scheme, through multimodal feature fusion and a dynamic elastic architecture, provides scalable, verifiable, and business-adaptable underlying support for blockchain-enabled agricultural traceability systems.

[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0028] Figure 1This is one of the flowcharts illustrating the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by this invention, such as... Figure 1 As shown, this invention provides a method for segmenting the agricultural product supply chain based on an improved Louvain algorithm, comprising the following steps: Step 110: Shard the nodes in the agricultural product supply chain based on the improved Louvain algorithm. The improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm. The reputation gain term is composed of the average reputation value of the nodes within the shard and the average reputation difference between shards.

[0029] Specifically, the traditional Louvain algorithm calculates the modularity of communities based solely on the weights of the edges connecting nodes. However, considering the application scenario of agricultural product traceability, a reputation gain term is introduced on the basis of the modularity of the traditional Louvain algorithm, taking into account the role attributes of nodes in the supply chain, to form an improved Louvain algorithm.

[0030] The expression for the modularity of the improved Louvain algorithm is shown below: In the formula, This indicates the modularity of the improved Louvain algorithm. This represents the modularity of the traditional Louvain algorithm. This indicates a reputation gain item.

[0031] Modularity of the traditional Louvain algorithm The expression is as follows: In the formula, This represents the sum of the weights of all edges. Represents a node With nodes Edge weights between them Represents nodes The sum of the weights of all connected edges. Represents nodes The sum of the weights of all connected edges. Represents a node The community to which it belongs Represents a node The community to which the node belongs, if With nodes If they belong to the same community, then If node With nodes Belonging to different communities, .

[0032] A reputation gain term is constructed based on the average reputation value of nodes within a shard and the average reputation difference between shards. This is done by iterating through each shard in the blockchain network, calculating the ratio for each shard—that is, the ratio between the average reputation value of nodes within a shard and the average reputation difference between shards (between that shard and other shards). The reputation gain term is obtained by summing all the ratios for each shard and multiplying them by a balancing coefficient. The expression is as follows: In the formula, This represents a balance coefficient (e.g., 0.1), which increases the reward for high-reputation clusters within a shard. This represents the average reputation value of the nodes within shard c. This represents the average reputation difference between shard c and other shards.

[0033] The core objective of introducing a reputation gain term into supply chain sharding algorithms is to enhance credibility within shards and encourage the clustering of high-reputation nodes. In a supply chain network, the clustering of high-reputation nodes (such as farmers who deliver on time and processors that meet quality inspection standards) can significantly reduce transaction risk within a shard. The reputation gain term... It directly measures the reliability of the shards; the higher the value, the more reliable the shards as a whole.

[0034] Average reputation value of nodes within shard c The expression is as follows: In the formula, This represents the average reputation value of the nodes within shard c. Indicates the nodes within partition c. Reputation value This represents the number of nodes within partition c.

[0035] The algorithm tends to group high-reputation nodes into the same shard, forming a high-quality business cluster and reducing the risk of transaction disputes or data tampering caused by low-reputation nodes. It also strengthens the differences between shards, establishing clear trust boundaries. The design logic is that if the reputation differences between shards are significant ( If the shards are large enough, then different shards can support different business roles (such as high-reputation shards handling cross-border trade, and ordinary shards handling local retail). This isolation reduces the scope of cross-shard attacks.

[0036] Average reputation difference between shard C and other shards The expression is as follows: In the formula, This represents the average reputation difference between fragment c and other fragments. Indicates the total number of fragments. This refers to all fragments other than fragment c. This represents the average reputation value of the nodes within shard c. Fragments The average reputation value of internal nodes.

[0037] The standard deviation of the reputation values ​​of shard c from those of other shards measures the difference in reputation distribution among shards. The greater the difference in reputation among shards, the more the algorithm tends to maintain the current partition, avoiding security ambiguity caused by reputation mixing.

[0038] The nodes are sharded based on the improved Louvain algorithm. That is, the modularity of the Louvain algorithm is improved by iterative optimization in two stages: first, the community to which the node belongs is locally adjusted; second, the communities are merged into supernodes to build a new network; and finally, a hierarchical community structure is output.

[0039] The agricultural product supply chain sharding method provided by this invention, based on the improved Louvain algorithm, introduces a reputation gain term based on the average reputation value of nodes within a shard and the average reputation difference between shards, on the basis of the modularity of the traditional Louvain algorithm. It designs a two-level optimization objective function, namely the collaborative optimization of "topology tightness + business credibility", so that the sharding structure can reduce cross-shard communication overhead, ensure the credibility and locality of business processes, and improve the adaptability of business locality.

[0040] In some embodiments, the nodes in the agricultural product supply chain are sharded based on the improved Louvain algorithm, including: The nodes in the agricultural product supply chain are layered based on role tags, resulting in multiple layers; each layer corresponds to a role tag. Within each layer, nodes are sharded based on the improved Louvain algorithm.

[0041] Specifically, a role-based hierarchical mechanism is designed for the vertical business processes of the agricultural industry chain, stratifying nodes in the agricultural product supply chain through role labels. For example, roles labeled as growers, processors, logistics providers, distributors, and regulatory agencies would be divided into production, processing, logistics, sales, and regulatory layers. Within each layer, nodes are fragmented based on an improved Louvain algorithm.

[0042] The agricultural product supply chain sharding method provided by this invention, based on the improved Louvain algorithm, hierarchically divides nodes in the agricultural product supply chain according to role tags. Within each layer, nodes are sharded based on the improved Louvain algorithm, that is, nodes are vertically divided according to role tags. Within each vertical layer, nodes are horizontally grouped. "Logical isolation" is achieved through business layering, and "efficiency optimization" is achieved through technical sharding. The combination of the two solves the problems of "storage explosion" and "cross-shard congestion" in agricultural product traceability of traditional blockchain.

[0043] In some embodiments, node sharding is performed based on the improved Louvain algorithm, including: Initialize the community to which each node belongs; For the current node, perform the following: determine the current node's neighboring communities; move the current node to each neighboring community, calculate the modularity gain for each neighboring community, and determine the neighboring community corresponding to the maximum modularity gain; if the maximum modularity gain is greater than 0, move the current node to the neighboring community corresponding to the maximum modularity gain. If the maximum modularity gain is greater than the modularity gain threshold, the next node is taken as the current node, and the above operation is performed. When the maximum modularity gain is equal to or less than the modularity gain threshold, nodes in the same community are merged into a super node to build a new network. This process is repeated until the modularity gain no longer increases, resulting in each shard.

[0044] Specifically, Figure 2 This is the second flowchart illustrating the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by this invention. Figure 2 As shown, it includes the following steps: Step 210: Determine the initial community to which each node belongs.

[0045] Specifically, for example, in the production layer, nodes are divided into communities according to planting areas (such as farmland grids), and IoT nodes such as soil sensors and irrigation equipment are incorporated.

[0046] For example, in the processing layer, nodes are divided into communities according to processing type (such as grain and oil processing, fruit and vegetable grading) and associated with processing equipment status data; For example, in the logistics layer, nodes are divided into communities according to logistics hubs (such as cold chain storage centers), and GPS tracks and temperature control data of transport vehicles are integrated; For example, regulators can independently segment data and mandate the inclusion of high-reputation nodes at each stage for real-time auditing and compliance verification.

[0047] Step 220: Determine the neighboring communities of the current node.

[0048] Specifically, for the current node, determine its neighboring communities. The specific process could be: for example, if the current node is a node... Get all neighboring nodes of the current node. And collect the community set to which the neighboring nodes belong. The community in the set of neighboring nodes is taken as the neighboring community of the current node.

[0049] It should be noted that the set of neighboring nodes' communities includes the node's own community. This design is a necessary strategy to improve the Louvain algorithm during the iterative optimization phase. During the iteration process, a node needs to determine "whether to migrate to another community," and its own community is an important benchmark, ensuring that the node has the option of "staying in its original community" in each iteration.

[0050] Step 230: Move the current node to each neighboring community, calculate the modularity gain for each neighboring community, and determine the neighboring community corresponding to the maximum modularity gain.

[0051] Specifically, the current node is moved to each neighboring community, and the modularity gain for each neighboring community is calculated. That is, for a given neighboring community, before the current node moves to that community, the modularity of that community is calculated and denoted as . After the current node moves to this neighboring community, calculate the modularity of that neighboring community, denoted as . Then the modularity gain corresponding to the neighboring community for .

[0052] From the modularity gains of all neighboring communities, determine the maximum modularity gain and the neighboring community corresponding to the maximum modularity gain.

[0053] Step 240: Determine whether the maximum modularity gain is greater than 0.

[0054] Specifically, if the maximum modularity gain is greater than 0, step 250 is executed; if the maximum modularity gain is less than or equal to 0, step 260 is executed.

[0055] Step 250: Move the current node to the neighbor community corresponding to the maximum modularity gain.

[0056] In some embodiments, if multiple communities have the same gain, the community with higher role synergy is given priority. It should be noted that although nodes within the same layer may have the same role label, role synergy essentially measures the "tightness of business association" rather than the consistency of role types. For example, the production layer includes roles such as "grower," "soil sensor," and "irrigation equipment," while the processing layer includes roles such as "processor" and "processing equipment." Nodes within the same layer may belong to the same business segment, but their specific role types may differ (e.g., grower and sensor), resulting in different business synergy methods.

[0057] Step 260: Do not move the current node.

[0058] Step 270: Determine whether the maximum module gain is less than the module gain threshold.

[0059] Specifically, to reduce the time consumed by the first-stage algorithm execution, a module gain threshold is set. If the maximum module gain is greater than or equal to the module gain threshold, step 280 is executed; if the maximum module gain is less than the module gain threshold, the first stage execution ends, and step 290 is executed.

[0060] Step 280: Set the next node as the current node.

[0061] Specifically, the next node is taken as the current node, and steps 220 to 270 are executed again.

[0062] Step 290: Merge nodes from the same community into super nodes, build a new network, and repeat the iteration until the modularity gain no longer increases.

[0063] Specifically, nodes from the same community are merged into a supernode to build a new network. This process is repeated iteratively until the modularity gain no longer increases, that is, until no significant modularity gain is achieved between successive phases.

[0064] After a node merges into a community, a new community is formed, requiring an internal weight update. The new community can be viewed as a supernode, whose internal connections create a self-loop. The weight of this loop is the sum of the weights of all connecting edges within the community. After merging nodes of the same type (i.e., nodes within the same region partitioned using the improved Louvain algorithm) into a supernode, the weights of the supernode and its connecting edges are updated. The connection weight between this supernode and other communities is the sum of the connection weights between the communities.

[0065] In some embodiments, the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by the present invention further includes: Fragments whose reputation variance is greater than the first threshold or whose ratio of cross-fragment interactions to internal interactions is greater than the second threshold will trigger reassembly.

[0066] Specifically, in response to the dynamic characteristics of node reputation in the agricultural product supply chain fluctuating with the seasons (such as the rainy season potentially affecting the on-time delivery rate of logistics companies) and transaction patterns changing with the production and sales cycle (such as the surge in transaction frequency between processors and farmers during the autumn harvest season), this invention designs a segmented dynamic maintenance strategy to ensure the stability and efficiency of the traceability system in the face of business changes.

[0067] Shard reorganization is triggered by a dual condition of "reputation value variance threshold + cross-shard transaction entropy". Reorganization is triggered when shard c meets any of the following conditions: In the formula, This represents the variance of the reputation score for segment c. Represents a node Reputation value This represents the average reputation of shard c. This represents the number of nodes in partition c. This indicates the number of cross-shard interactions in shard c. This indicates the number of interactions within shard c. Indicates the first threshold. , This represents the second threshold. .

[0068] For each fragment c, check the reorganization condition. If it is triggered, return to the first stage. If it is not triggered, return the final fragmentation result.

[0069] For example, when a processor in a certain region causes its reputation variance to exceed the threshold due to raw material quality issues (such as when an agricultural product processor fails to meet quality inspection standards for three consecutive batches, triggering a reputation anomaly alarm within the segment), the system prioritizes isolating low-reputation nodes and initiating local reorganization to prevent substandard processors from affecting the credibility of traceability data across the entire segment.

[0070] If the cross-segment transaction entropy exceeds the threshold (e.g., if the cross-segment transaction ratio between a logistics provider in a production area and a retail area is consistently higher than 40%, it indicates that the existing segmentation has fragmented the high-frequency business connections), then the segmentation boundaries are lightly adjusted through the adaptive MCMC algorithm to ensure that the logistics provider and the high-frequency cooperative retailer are grouped into the same segment, thereby reducing cross-segment communication overhead.

[0071] We chose to use a time-series forecasting model to anticipate changes in business traffic and proactively adjust the segmentation structure. On one hand, we trained the model using historical data, analyzing agricultural product production and sales data from the past five years to establish a "season-region-transaction volume" forecasting model. On the other hand, we implemented pre-adjustment strategies. For example, one month before the peak season (such as the Spring Festival), we automatically created "temporary peak season segments," pre-allocated logistics and warehousing node resources, and flexibly scaled them down. After the peak season ended, the temporary segments were automatically disbanded, and the nodes returned to their original segments.

[0072] This invention provides a sharding method for agricultural product supply chains based on an improved Louvain algorithm, which designs a dynamic maintenance mechanism for trusted communities. On one hand, a reputation variance threshold triggering mechanism is established. When the reputation variance of nodes within a shard exceeds a preset threshold, shard reorganization is automatically triggered, ensuring the stability of node reputation levels within the community. On the other hand, cross-shard transaction ratio constraints are set to achieve rapid isolation of low-reputation nodes, ensuring the trustworthiness and robustness of the sharding structure. This strategy dynamically balances the homogeneity within the community with the need for cross-community collaboration, while providing a reliable structural foundation for subsequent cross-shard transactions.

[0073] In some embodiments, the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by the present invention further includes: The edge weights between two nodes are constructed based on the transaction closeness, geographical proximity, reputation correlation, and role correlation between them.

[0074] Specifically, multi-dimensional feature extraction is performed on node attributes. Building upon the modularity of the traditional Louvain algorithm, multi-factor weights related to the supply chain are introduced. Specifically, key parameters such as transaction density, geographical proximity, reputation correlation, and role correlation between nodes are embedded into the edge weight model. Transaction density reflects the frequency of business interactions between nodes and is an important indicator of supply chain activity. Geographical proximity considers the impact of spatial distance on logistics costs and transportation timeliness, and is significant for optimizing supply chain layout. The reputation correlation between nodes plays a crucial role throughout the entire agricultural product supply chain sharding process. On the one hand, it guides high-reputation nodes to cluster in the same shard; for example, high-reputation growers and high-reputation processors are grouped into the same shard due to their high reputation correlation. On the other hand, it isolates low-reputation nodes, reducing risk diffusion. If a node has low reputation correlation with other nodes in a shard, the algorithm will migrate it to a low-reputation shard or an observation shard through modularity gain calculation, avoiding contamination of the high-reputation cluster. Role correlation is used to quantify the business role synergy between nodes.

[0075] By integrating transaction density, geographical proximity, reputation correlation, and role correlation between two nodes, the edge weight between them is constructed. The expression for the edge weight between two nodes is as follows: In the formula, Represents a node With nodes Edge weights between them Represents a node With nodes The closeness of transactions between them (e.g., the standardized value of the number of transactions in the last 30 days). This indicates the weight corresponding to the closeness of the transaction. Represents a node With nodes Geographical proximity between them The weights representing geographical proximity are... Represents a node With nodes The degree of credibility between them This indicates the weight corresponding to the reputation correlation. Represents a node With nodes The degree of relationship between the roles This indicates the weight corresponding to the role relevance.

[0076] Therefore, the weight allocation strategy can be: the production process is dominated by transaction closeness and geographical proximity, thus setting... The warehousing process is primarily driven by geographical proximity and reputational correlation; therefore, it is designed with... The logistics process is primarily driven by the closeness of transactions and the degree of role correlation; therefore, it is designed with... The sales process is primarily driven by the closeness of transactions and the strong connection of reputation; therefore, it is designed with... The regulatory process prioritizes credibility and role-related authority, therefore it is set up as follows: .

[0077] Traditional Louvain's algorithm, when dealing with agricultural supply chain issues, focuses solely on topological density, leading to a mismatch with the business attributes of the supply chain. In a supply chain, the frequency of business interactions between nodes significantly impacts their connectivity; agricultural production and transportation are heavily influenced by geographical factors; and the reputation level of each node is crucial for the stable operation of the supply chain. These factors all enhance the coherence of business processes, making the sharding structure more aligned with the business processes of the agricultural supply chain. This invention provides an agricultural supply chain sharding method based on an improved Louvain's algorithm. This method constructs edge weights between nodes based on transaction density, geographical proximity, reputational correlation, and role correlation, thus resolving the mismatch between traditional Louvain's algorithm and the business attributes of the supply chain.

[0078] In some embodiments, the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by the present invention further includes: Roles are assigned to each node according to the upstream and downstream sequence of the agricultural product supply chain; The role association between the two nodes is determined based on their role codes; the two nodes are those with business relationships.

[0079] Specifically, the role association degree between nodes is introduced into the edge weight function of the traditional Louvain algorithm to quantify the business role synergy between nodes.

[0080] Following the upstream and downstream sequence of the agricultural product supply chain, each node is assigned a role code. There must be a code difference between nodes; the smaller the code difference, the closer the business collaboration between nodes. For two nodes with business relationships, the degree of role association between the two nodes is determined based on their role codes.

[0081] The expression for role relevance is as follows: In the formula, Represents a node With nodes The degree of relationship between the roles Represents a node Role coding, Represents a node Role coding, This indicates the maximum coding difference in roles within the agricultural product supply chain.

[0082] For example, the upstream and downstream sequence of the agricultural product supply chain is grower --> processor --> logistics provider --> seller --> regulatory node. Therefore, grower is coded as 1, processor as 2, logistics provider as 3, seller as 4, and regulatory node as 5. At this time, K=4, which corresponds to the distance between grower and regulatory node.

[0083] For nodes with the same role (two planting nodes): ,but This indicates complete collaboration; for nodes with similar roles (processors and logistics providers): ,but This indicates a strong correlation; for cross-linking points (growers and distributors): ,but , indicating a weak association.

[0084] In some embodiments, the agricultural product supply chain segmentation method based on the improved Louvain algorithm provided by the present invention further includes: The reputation value of each node is determined based on the transaction fulfillment rate and regulatory rating after standardized processing. The reputation values ​​of two nodes are weighted and fused to obtain the reputation correlation between the two nodes.

[0085] Specifically, the reputation correlation between nodes is introduced into the edge weight function of the traditional Louvain algorithm.

[0086] A node's reputation score is calculated based on historical data recorded on the blockchain, specifically transaction fulfillment data and regulatory ratings. It primarily employs the Min-Max standardization method, requiring data standardization to map the data to the [0,1] range.

[0087] in, This represents the standardized reputation data. This is the raw reputation data (transaction performance data and regulatory rating) for node i. and These are the maximum and minimum values ​​of the overall data range.

[0088] The standardized transaction fulfillment rate and regulatory rating are weighted and fused to obtain the reputation score of the node. The weights corresponding to the transaction fulfillment rate and regulatory rating can be selected according to the actual situation.

[0089] For example: The transaction fulfillment rate is 90%, [min,max]=[50%,100%], and the regulatory rating is 90 points, [min,max]=[60,100]. After standardization, the transaction fulfillment rate is 0.8, and the regulatory rating is 0.75. With weights of 0.5 for the transaction fulfillment rate and regulatory rating, respectively, the final reputation value of this node is... .

[0090] After obtaining the reputation scores of each node, the reputation scores of two nodes are weighted and fused to obtain the reputation correlation between the two nodes. The weights corresponding to the two nodes can be selected according to the actual situation.

[0091] For example, when the weights of the two nodes are 0.5 and 0.5 respectively, the expression for the reputation association between the two nodes is as follows: In the formula, Represents a node With nodes The degree of credibility between them Represents a node Reputation value Represents a node Reputation value.

[0092] The following describes the agricultural product supply chain segmentation device based on the improved Louvain algorithm provided by the present invention. The agricultural product supply chain segmentation device based on the improved Louvain algorithm described below can be referred to in correspondence with the agricultural product supply chain segmentation method based on the improved Louvain algorithm described above.

[0093] Figure 3 This is a schematic diagram of the agricultural product supply chain segmentation device based on the improved Louvain algorithm provided by the present invention, as shown below. Figure 3 As shown, this invention provides an agricultural product supply chain segmentation device based on an improved Louvain algorithm, comprising: Sharding module 310 is used to shard nodes based on the improved Louvain algorithm; the improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm, and the reputation gain term is composed of the average reputation value of nodes within the shard and the average reputation difference between shards.

[0094] In some embodiments, the sharding module 310 includes: The hierarchical unit is used to divide the nodes in the agricultural product supply chain into layers based on role tags, resulting in multiple layers; each layer corresponds to a role tag. The sharding unit is used to shard nodes in the agricultural product supply chain within each layer based on the improved Louvain algorithm.

[0095] In some embodiments, the fragmentation unit is specifically used for: Determine the initial community to which each node belongs; For the current node, perform the following: determine the neighboring communities of the current node; move the current node to each of the neighboring communities, calculate the modularity gain corresponding to each of the neighboring communities, and determine the neighboring community corresponding to the maximum modularity gain; if the maximum modularity gain is greater than 0, move the current node to the neighboring community corresponding to the maximum modularity gain. If the maximum modularity gain is greater than the modularity gain threshold, the next node is taken as the current node; If the maximum modularity gain is equal to or less than the modularity gain threshold, nodes in the same community are merged into supernodes to build a new network. This process is repeated iteratively until the modularity gain no longer increases.

[0096] In some embodiments, the apparatus further includes: a trigger reorganization module, configured to trigger reorganization for fragments whose reputation variance is greater than a first threshold or whose ratio of cross-fragment interaction count to internal interaction count is greater than a second threshold.

[0097] In some embodiments, the apparatus further includes: The construction module is used to construct the edge weight between two nodes based on the transaction closeness, geographical proximity, reputation correlation, and role correlation between the two nodes.

[0098] In some embodiments, the apparatus further includes: The role coding module is used to assign roles to each node according to the upstream and downstream sequence of the agricultural product supply chain. The first determining module is used to determine the role association degree between the two nodes based on the role codes of the two nodes; the two nodes are two nodes that have a business relationship.

[0099] In some embodiments, the apparatus further includes: The second determination module is used to determine the reputation value of each node based on the standardized transaction fulfillment rate and regulatory rating of each node. The weighted fusion module is used to perform weighted fusion of the reputation values ​​of the two nodes to obtain the reputation correlation between the two nodes.

[0100] It should be noted that the agricultural product supply chain segmentation device based on the improved Louvain algorithm provided by the present invention can realize all the method steps implemented in the above method embodiments and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiments and the beneficial effects will not be described in detail.

[0101] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 4 As shown, the electronic device may include a processor 410, a communications interface 420, a memory 430, and a communication bus 440. The processor 410, communications interface 420, and memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute an agricultural product supply chain sharding method based on an improved Louvain algorithm. This method includes sharding nodes in the agricultural product supply chain based on the improved Louvain algorithm. The improved Louvain algorithm introduces a reputation gain term based on the modularity of the traditional Louvain algorithm. The reputation gain term is based on the average reputation value of nodes within a shard and the average reputation difference between shards.

[0102] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0103] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the agricultural product supply chain sharding method based on the improved Louvain algorithm provided by the above methods. The method includes: sharding nodes in the agricultural product supply chain based on the improved Louvain algorithm; the improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm, and the reputation gain term is composed of the average reputation value of nodes within the shard and the average reputation difference between shards.

[0104] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described methods for sharding agricultural product supply chains based on the improved Louvain algorithm. The method includes: sharding nodes in the agricultural product supply chain based on the improved Louvain algorithm; wherein the improved Louvain algorithm introduces a reputation gain term on the basis of the modularity of the traditional Louvain algorithm, and the reputation gain term is composed of the average reputation value of nodes within a shard and the average reputation difference between shards.

[0105] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0106] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for segmenting the agricultural product supply chain based on an improved Louvain algorithm, characterized in that, include: Segmenting nodes in the agricultural product supply chain based on an improved Louvain algorithm; The improved Louvain algorithm introduces a reputation gain term based on the modularity of the traditional Louvain algorithm. The reputation gain term is composed of the average reputation value of nodes within a shard and the average reputation difference between shards.

2. The method for segmenting the agricultural product supply chain based on the improved Louvain algorithm according to claim 1, characterized in that, The method of sharding nodes in the agricultural product supply chain based on the improved Louvain algorithm includes: The nodes in the agricultural product supply chain are layered based on role tags, resulting in multiple layers; each layer corresponds to a role tag. Within each layer, nodes are sharded based on the improved Louvain algorithm.

3. The agricultural product supply chain segmentation method based on the improved Louvain algorithm according to claim 2, characterized in that, The node sharding based on the improved Louvain algorithm includes: Determine the initial community to which each node belongs; For the current node, perform the following: determine the neighboring communities of the current node; move the current node to each of the neighboring communities, calculate the modularity gain corresponding to each of the neighboring communities, and determine the neighboring community corresponding to the maximum modularity gain; if the maximum modularity gain is greater than 0, move the current node to the neighboring community corresponding to the maximum modularity gain. If the maximum modularity gain is greater than the modularity gain threshold, the next node is taken as the current node; If the maximum modularity gain is equal to or less than the modularity gain threshold, nodes in the same community are merged into supernodes to build a new network. This process is repeated iteratively until the modularity gain no longer increases.

4. The agricultural product supply chain segmentation method based on the improved Louvain algorithm according to claim 3, characterized in that, The method further includes: Fragments whose reputation variance is greater than the first threshold or whose ratio of cross-fragment interactions to internal interactions is greater than the second threshold will trigger reassembly.

5. The agricultural product supply chain segmentation method based on the improved Louvain algorithm according to claim 1, characterized in that, The method further includes: The edge weights between the two nodes are constructed based on the transaction closeness, geographical proximity, reputation correlation, and role correlation between them.

6. The agricultural product supply chain segmentation method based on the improved Louvain algorithm according to claim 5, characterized in that, The method further includes: Roles are assigned to each node according to the upstream and downstream sequence of the agricultural product supply chain; The role association degree between the two nodes is determined based on their role codes; the two nodes are two nodes that have a business relationship.

7. The method for segmenting the agricultural product supply chain based on the improved Louvain algorithm according to claim 5, characterized in that, The method further includes: The reputation value of each node is determined based on the transaction fulfillment rate and regulatory rating after standardized processing. The reputation values ​​of the two nodes are weighted and fused to obtain the reputation correlation between the two nodes.

8. A segmentation device for agricultural product supply chain based on an improved Louvain algorithm, characterized in that, include: The sharding module is used to shard nodes in the agricultural product supply chain based on the improved Louvain algorithm; The improved Louvain algorithm introduces a reputation gain term based on the modularity of the traditional Louvain algorithm. The reputation gain term is composed of the average reputation value of nodes within a shard and the average reputation difference between shards.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the agricultural product supply chain segmentation method based on the improved Louvain algorithm as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the agricultural product supply chain segmentation method based on the improved Louvain algorithm as described in any one of claims 1 to 7.