I have few days to complete my awk homework. But I'm stucked. i hope some1 will help me out.
I have to inverse n x n matrix, but I have problems with finding the determinant of the matrix.
I found the algoritm, how to find a determinant of n x n matrix:... (0 Replies)
Hi power user,
I have this type of data (distance list):
file1
A B 10
B C 20
C D 50I want output like this
# A B C D
A 0 10 30 80
B 10 0 20 70
C 30 20 0 50
D 80 70 50 0 Which is a distance matrix
I have tried... (0 Replies)
hi there
I'm very new in programing and i've started with awk.
I'm processing 200 data files and I need to do some precessing on them.
The files have 3 columns with N-lines
for each line a have on the first and second value is the same for all the files and only the third is variable. like... (2 Replies)
Hi all,
Is there a way to convert full data matrix to linearised left data matrix?
e.g full data matrix
Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7
Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245
Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Hi there,
If anyone can help me sorting out this small task would be great. Given a matrix like the following:
100 3 3 3 3 3 ...
200 5 5 5 5 5 ...
400 1 1 1 1 1 ...
500 8 8 8 8 8 ...
900 0 0 0 0... (5 Replies)
Greetings, salutations.
I have a 3 column csv file with ~13 million rows and I would like to generate a correlation matrix. Interestingly, you all previously provided a solution to the inverse of this problem. Thread title: "awk? adjacency matrix to adjacency list / correlation matrix to list"... (6 Replies)
dear awk gurus,
i would need a fast (therefore) awk solution for the reformation of an uncomplete weighted adjacency list to a complete sorted adjacency matrix.
example (FS=OFS=,):
a,d,0.33
a,b,0.25
b,c,0.11
should give:
,a,b,c,d
a,1,0.25,0,0.33
b,0.25,1,0.11,0... (4 Replies)
I want to go from
1,a,1a
1,b,1b
1,c,1c
2,a,2a
2,b,2b
3,a,3a
to
a,b,c
1,1a,1b,1c
2,2a,2b,-
3,3a,-,-
Here is what I tried
awk -F, 'BEGIN {OFS = ","} (4 Replies)
input
A1 B1 A2 B2
0 0 1 1
1 0 0 1
0 1 1 0
1 1 1 1
Output
label A1 B1 A2 B2
A1 2 1 1 2
B1 1 2 2 1
A2 1 2 3 2
B2 2 1 2 3
Ex:
The number of times that A1 and B1 row values are both 1 should be printed as output.
The last row of A1 and B1 in the input match by having 1 in both... (4 Replies)
Discussion started by: quincyjones
4 Replies
LEARN ABOUT DEBIAN
graph::adjacencymatrix
Graph::AdjacencyMatrix(3pm) User Contributed Perl Documentation Graph::AdjacencyMatrix(3pm)NAME
Graph::AdjacencyMatrix - create and query the adjacency matrix of graph G
SYNOPSIS
use Graph::AdjacencyMatrix;
use Graph::Directed; # or Undirected
my $g = Graph::Directed->new;
$g->add_...(); # build $g
my $am = Graph::AdjacencyMatrix->new($g);
$am->is_adjacent($u, $v)
my $am = Graph::AdjacencyMatrix->new($g, distance_matrix => 1);
$am->distance($u, $v)
my $am = Graph::AdjacencyMatrix->new($g, attribute_name => 'length');
$am->distance($u, $v)
my $am = Graph::AdjacencyMatrix->new($g, ...);
my @V = $am->vertices();
DESCRIPTION
You can use "Graph::AdjacencyMatrix" to compute the adjacency matrix and optionally also the distance matrix of a graph, and after that
query the adjacencyness between vertices by using the "is_adjacent()" method, or query the distance between vertices by using the
"distance()" method.
By default the edge attribute used for distance is "w", but you can change that in new(), see below.
If you modify the graph after creating the adjacency matrix of it, the adjacency matrix and the distance matrix may become invalid.
Methods
Class Methods
new($g)
Construct the adjacency matrix of the graph $g.
new($g, options)
Construct the adjacency matrix of the graph $g with options as a hash. The known options are
distance_matrix => boolean
By default only the adjacency matrix is computed. To compute also the distance matrix, use the attribute "distance_matrix"
with a true value to the new() constructor.
attribute_name => attribute_name
By default the edge attribute used for distance is "w". You can change that by giving another attribute name with the
"attribute_name" attribute to new() constructor. Using this attribute also implicitly causes the distance matrix to be
computed.
Object Methods
is_adjacent($u, $v)
Return true if the vertex $v is adjacent to vertex $u, or false if not.
distance($u, $v)
Return the distance between the vertices $u and $v, or "undef" if the vertices are not adjacent.
adjacency_matrix
Return the adjacency matrix itself (a list of bitvector scalars).
vertices
Return the list of vertices (useful for indexing the adjacency matrix).
ALGORITHM
The algorithm used to create the matrix is two nested loops, which is O(V**2) in time, and the returned matrices are O(V**2) in space.
SEE ALSO
Graph::TransitiveClosure, Graph::BitMatrix
AUTHOR AND COPYRIGHT
Jarkko Hietaniemi jhi@iki.fi
LICENSE
This module is licensed under the same terms as Perl itself.
perl v5.10.0 2005-04-16 Graph::AdjacencyMatrix(3pm)