Abstract

The stock trading relationship of buyers and sellers in the stock market can be characterized by a directed graph. It is an important way to study stock trading network through simple directed paths and cycles. In the present paper, we establish a seeking model of simple directed paths and cycles, and obtain some necessary and sufficient conditions for simple directed path and cycle in the directed graph. The algorithms of finding simple directed path and cycle of any specified length are given. The main approach we used is the semi-tensor product of matrices, which can reduce the search space. An illustrative example is given to show that the theoretical results and algorithms are effective.

1. Introduction and Preliminaries

Complex systems are composed of multiple interacting components, and such systems are ubiquitous in social life, such as power grids, social networks, economic organization systems, and so on. Stock market, as a kind of complex system, is an important component in financial system, such as 3000 stocks affect each other and interact with the other in China’s A stock market. It is obvious to study the stock market from the perspective of complex network. The complex network is mathematically processed to form a graph [1, 2]. Although networks are everywhere, any network can be described by graph theory, such as the network of relationships, for example, traffic flow and pipeline transportation are related to the directed graph.

An NP-hard problem of graph theory is finding a simple path and cycle [3]. For simple path and cycle finding, an iterative algorithm based on variable adjacency matrix is illustrated in [4]. An improved adjacency matrix is obtained and a modified iteration rule is further given in [5], which develops the calculation speed. Furthermore, an adjacency matrix power algorithm is obtained by using Warshall’s theorem [6] to exhibit the simple path. An backtrack algorithm is presented for listing the whole simple paths in a directed graph [7] and listing the whole cycles in an undirected graph [8]. The search space algorithms are proposed in [9] for looking for every simple cycle of a planar graph. A new algorithm is developed to list approximately the cycle in an undirected graph on the basis of Compute Unified Device Architecture [10]. A new method called semi-tensor product (STP) of matrices is used to find a simple path and simple cycle in the undirected graph [11].

In this paper, we investigate the simple directed path and simple directed cycle in directed graph by STP method. STP was first proposed in [12, 13], which is a generalization of the usual matrix multiplication. It is successfully and maturely applied to Boolean control networks expressed as a discrete algebraic system [1316], and is further applied to a larger range, such as algebra [17], physics [18], and graph theory [19, 20]. The main contribution of the present paper is as follows: (i) we look for the simple directed paths and cycles by STP method after modeling the stock trading network as a directed graph, which has the mathematical formulation advantage by comparing the existing methods of finding the simple directed path and cycle. (ii) A new algorithm is derived to list the simple directed path and simple directed cycle in the directed graph, which can reduce the search space and is confirmed by an example.

The rest of this paper is organized as follows. The modeling of stock trading relationship and the analysis of finding simple directed path and cycle by STP method are given in Section 2. In Section 3, a new algorithm is illustrated based on the results in Section 2, and an illustrative example is presented to verify the effectiveness of the theoretical results and algorithms.

2. Modeling and Analysis

In this section, we introduce the modeling of stock trading relationship and investigate the simple directed path and cycle of the directed graph by using STP method.

For stock trading, the typical method is to regard every trader in the stock market as a node and the trading relationship between two investors as an edge. If there is no edge connection between two nodes, then there is no trade between the corresponding traders. In this network, the traders form the node set of a graph, and the trading relationships among all the investors form the edge set of a graph. Since there are buyers and sellers in stock trading, the trading relationship is directional. Therefore, the stock trading network can be characterized as a directed graph by assembling nodes and edges.

Consider a graph with a vertex (node) set and an edge set . A graph is called a directed graph if each edge of , denoted by , is an ordered pair of two vertices. In a directed graph , a directed path consists of the ordered edges . A directed cycle is a directed path with some first vertex and last vertex. Simple directed path (cycle) refers to a path (cycle) with distinct vertices. The -simple directed path (cycle) is a simple directed path (cycle) with vertices, for example, and are 4-simple directed path and 3-simple directed cycle in Figure 1, respectively.

For the vertex , the neighbor vertex set is given by

Then the adjacency matrix of is described as

For the vertex subset with , the characteristic logical vector of is given as , where

Then we have the following results.

Theorem 1. Assume that , . Then the directed subgraph induced by vertex set is a -simple directed path if and only if the following assumptions hold. (i)One element of the matrix is 0 and the other elements are 1, where is given by(ii)If for with , then .(iii)The subset satisfieswhere

Proof (Necessity). If is a -simple directed path, then the connection relationship of vertices and edges in can be described in Figure 2.

In the directed graph in Figure 2, we find that the end vertex has no adjacent vertex and the remaining vertices have one adjacent vertex in set . Then, one element of satisfies and the other elements of satisfy . That is to say, one element of the matrix is 0 and the other elements are 1.

Assume that for with . Suppose , then it contradicts the definition of a simple directed path, and so we have .

For any subset with elements, it is obvious that

(Sufficiency) If one element of the matrix is 0 and the remaining elements are 1, then one element of meets , and elements of meet . Thus, one vertex of has no adjacent vertex described by type I, and the remaining vertices of have one adjacent vertex described by type II (see Figure 3). Hence, the vertex of type I is the end vertex in the directed graph.

In what follows, we prove that all vertices of type II can be described in Figure 3, which shows that is a -simple directed path.

Suppose, there exist some vertices with type II not described in Figure 3. Then, either there are two vertices satisfying for , or there is a subset such that

The above results have contradiction with conditions (ii) and (iii). Therefore, all vertices with type II are described in Figure 3.

Remark 2. If , then is a -simple directed path if and only if satisfies conditions (i) and (ii) in Theorem 1.

Corollary 3. Assume that , . Then the directed subgraph induced by vertex set is a -simple directed cycle if and only if the following assumptions hold. (i).(ii)If for with , then .(iii)The subset satisfieswhere

Remark 4. If , then is the -simple directed cycle if and only if satisfies conditions (i) and (ii) of Corollary 3.
For further discussion, the structure matrices for the Boolean operators are given as follows (see [19]). The structure matrices of conjunction operator and dummy operator are and , respectively.

Proposition 5. holds for logical variables .

Proposition 6. , where , , and the element of the swap matrix , denoted by , is given by

Theorem 7. Assume that and with . If is a -simple directed path, then the th component of the first row in matrix is , where

Proof. When is the -simple directed path, we have Due to , without loss of generality, in this paper we can assume that . From Propositions 5 and 6, we have From (14), we obtain where . Thus, it follows from (15) that It follows from that the th component of the first row of matrix is .

Corollary 8. Assume that and . If is a -simple directed cycle, then the th component of the first row of matrix is , where

3. Algorithm and Validity

In this section, we give the algorithm for finding the -simple directed path (cycle) in the directed graph based on the above section.

Step 1. It is easy to derive by (12). The first row of is obtained by using , described as . When for all , there exist no -simple directed paths and the program is terminated. When for some , the position numbers where the element is are given by .

Step 2. Each corresponds to a . From [13], we know that Then we obtain When , there is not -simple directed path, and the program is terminated. Otherwise, only the sets with vertices are considered.

Step 3. Test whether the above sets with vertices satisfy the condition of Theorem 1. The directed subgraphs that meet the condition of Theorem 1 are all -simple directed paths.

Remark 9. In combination with Corollary 3, the algorithm of looking for all the -simple directed cycles can be derived in the same way.

In what follows, we give an example to verify the validity of algorithm. The given directed graph is shown in Figure 4, and the MATLAB software is used to search for the simple directed path and simple directed cycle in the directed graph. An example with 8-simple directed path is given to verify that the algorithm above is efficient and reliable.

The adjacency matrix of the directed graph in Figure 4 is denoted as

is easily obtained according to Step 1 of the above algorithm, and the columns whose element is 7 are denoted by , which are all elements that may form 8-simple directed paths. According to Step 2 of the algorithm, there are only 25 sets with 8 elements. By Step 3, there is only one 8-simple directed path in the complex directed graph, which is shown in Table 1, and there is no 9-simple directed cycle.

Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Acknowledgments

This work is supported by the National Natural Science Foundation of China (No.12061081), the Yulin Science and Technology Plan (Nos.2019-94-5, CXY-2020-005-2) and the Doctor Start-up Research Fund of Yulin University (No.20GK22). The authors wish to express their appreciation for the research perspectives in the conference manuscript entitled “A new algebraic approach to finding all simple paths and cycles in undirected graphs”.